async def on_member_join(member: discord.member):
    try:
        with open("Files/Stats.json", "r") as f:
            stats = json.load(f)
        channel = bot.get_channel(stats[str(member.guild.id)])
        await channel.edit(name=F"All Members: {member.guild.member_count}")
    except KeyError:
        pass
    try:
        with open("Files/join_leave.json") as f:
            join = json.load(f)
        server = join[str(member.guild.id)]
        channel = bot.get_channel(server['welcome'])
        embed = discord.Embed(
            title=
            F"Welcome to {member.guild}, Get started by looking through the announcements channels and info channels!",
            color=0x0000ff)
        embed.set_author(name=F"{member.name} Welcome to {member.guild}")
        embed.set_thumbnail(url=member.avatar_url)
        embed.set_footer(
            text=
            F"{member.guild} | Member count: {member.guild.member_count} | {time.asctime()}"
        )
        await channel.send(embed=embed)
    except KeyError:
        pass
async def on_member_remove(member: discord.member):
    try:
        with open("Files/Stats.json") as f:
            stats = json.load(f)
        channel = bot.get_channel(stats[str(member.guild.id)])
        await channel.edit(name=F"All Members: {member.guild.member_count}")
    except KeyError:
        pass
    try:
        with open("Files/join_leave.json") as f:
            leave = json.load(f)
        server = leave[str(member.guild.id)]
        channel = bot.get_channel(server['goodbye'])
        embed = discord.Embed(
            title=
            F"Goodbye {member}, You will be missed, or maybe not we don't know. ¯\_(ツ)_/¯",
            color=0xff0000)
        embed.set_author(name=F"{member} left {member.guild}")
        embed.set_thumbnail(url=member.avatar_url)
        embed.set_footer(
            text=
            F"{member.guild} | Member count: {member.guild.member_count} | {time.asctime()}"
        )
        await channel.send(embed=embed)
    except KeyError:
        pass
Exemplo n.º 3
0
async def on_message(message):
    if not message.author.bot:
        mentions = [str(m) for m in message.mentions]
        with open("Files/Prefix.json") as f:
            prefixes = json.load(f)
        prefix = prefixes.get(str(message.guild.id))
        if str(bot.user) in list(mentions):
            channel = bot.get_channel(message.channel.id)
            if prefix is None:
                prefix = ">"
            await channel.send(F"***My prefix is*** `{prefix}`")
        with open("Files/Stop_Start_Rank.json") as f:
            stop_start = json.load(f)
        server = stop_start[str(message.guild.id)]
        if server["text"]:
            if not str(message.content).startswith(str(prefix)):
                if await Cooldown(message, 60):
                    with open("Files/TextRanking.json", "r") as f:
                        rank = json.load(f)
                    try:
                        test = rank[str(message.guild.id)]
                        new_user = True
                        for x in test['users']:
                            if x["name"] == str(message.author.id):
                                x['message'] += 1
                                x['xp'] += rand_xp
                                if x['xp'] >= x['next_xp']:
                                    x['xp'] = (x['xp'] - x['next_xp'])
                                    x['next_xp'] += 100
                                    x['level'] += 1
                                    channel = bot.get_channel(
                                        message.channel.id)
                                    await channel.send(
                                        F"{message.author.mention} congrats you are now level {x['level']}"
                                    )
                                new_user = False
                                break
                        if new_user:
                            test['users'].append({
                                'name': str(message.author.id),
                                'xp': rand_xp,
                                'next_xp': 100,
                                'level': 0,
                                'message': 1
                            })
                    except KeyError:
                        rank[str(message.guild.id)] = {"users": []}
                        test = rank[str(message.guild.id)]
                        test['users'].append({
                            'name': str(message.author.id),
                            'xp': rand_xp,
                            'next_xp': 100,
                            'level': 0,
                            'message': 1
                        })
                    with open("Files/TextRanking.json", "w") as f:
                        json.dump(rank, f, indent=4)
        await bot.process_commands(message)
Exemplo n.º 4
0
async def suggestions(ctx, *, suggestion):
    with open("Files/Suggestions.json", "r") as f:
        server = json.load(f)
    try:
        channel = bot.get_channel(server[str(ctx.guild.id)])
        embed = discord.Embed(
            title=F"{ctx.author} has a suggestions for the server",
            description=suggestion,
            color=0x0080ff)
        embed.set_author(name=ctx.author.name, icon_url=ctx.author.avatar_url)
        msg = await channel.send(
            embed=embed
        )  # https://cog-creators.github.io/discord-embed-sandbox/
        await msg.add_reaction("👍")
        await msg.add_reaction("👎")
        await ctx.send("the message has been sent")
    except KeyError:
        await ctx.send("The suggestions has not been set up yet")
Exemplo n.º 5
0
async def send(ctx, channel: discord.TextChannel, *, word):
    channel = bot.get_channel(channel.id)
    await channel.send(word)