Пример #1
0
async def prefixes_for(guild):
    _guild = Guild.find_one({'guild_id': str(guild.id)})
    if not _guild:
        guild_template = {
            'guild_id': str(guild.id),
            'name': guild.name,
            'prefix': config.prefix
        }
        guild_id = Guild.insert_one(guild_template).inserted_id
        _guild = Guild.find_one({'guild_id': str(guild.id)})

    return _guild.prefix
Пример #2
0
    async def on_guild_join(self, guild):
        guild_template = {
            'guild_id': str(guild.id),
            'name': guild.name,
            'prefix': self.config.prefix
        }
        guild_id = Guild.insert_one(guild_template).inserted_id
        print(chalk.cyan(f"Joined Guild > ") + chalk.yellow(f'{guild.name}'))
        if not self.config.join_message:
            return

        try:
            to_send = sorted([chan for chan in guild.channels if
                              chan.permissions_for(guild.me).send_messages and isinstance(chan, discord.TextChannel)],
                             key=lambda x: x.position)[0]
        except IndexError:
            pass
        else:
            await to_send.send(self.config.join_message)
            botguild = next((item for item in self.bot.guilds if item.id == 615228970568515626), None)
            log = botguild.get_channel(625767405641007106)
            await log.send(f"```css\nJoined Guild > {guild.name}```")