微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Python discord 模块-Invite() 实例源码

Python discord 模块,Invite() 实例源码

我们从Python开源项目中,提取了以下3代码示例,用于说明如何使用discord.Invite()

项目:Shallus-Bot    作者:cgropp    | 项目源码 | 文件源码
def join(self, invite_url: discord.Invite=None):
        """Joins new server"""
        if hasattr(self.bot.user, 'bot') and self.bot.user.bot is True:
            # Check to ensure they're using updated discord.py
            msg = ("I have a **BOT** tag,so I must be invited with an OAuth2"
                   " link:\nFor more information: "
                   "https://twentysix26.github.io/"
                   "Red-Docs/red_guide_bot_accounts/#bot-invites")
            await self.bot.say(msg)
            if hasattr(self.bot, 'oauth_url'):
                await self.bot.whisper("Here's my OAUTH2 link:\n{}".format(
                    self.bot.oauth_url))
            return

        if invite_url is None:
            await self.bot.say("I need a discord Invite link for the "
                               "server you want me to join.")
            return

        try:
            await self.bot.accept_invite(invite_url)
            await self.bot.say("Server joined.")
            log.debug("We just joined {}".format(invite_url))
        except discord.NotFound:
            await self.bot.say("The invite was invalid or expired.")
        except discord.HTTPException:
            await self.bot.say("I wasn't able to accept the invite."
                               " Try again.")
项目:dogbot    作者:slice    | 项目源码 | 文件源码
def invite_info(self, ctx, invite: discord.Invite):
        """Shows information about an invite."""
        embed = discord.Embed(title=f'Invite for {invite.guild.name} (`{invite.guild.id}`)')
        embed.add_field(name='Channel', value=f'{invite.channel.name} (`{invite.channel.id}`)', inline=False)
        if invite.inviter:
            embed.add_field(name='Inviter', value=describe(invite.inviter, mention=True), inline=False)
        await ctx.send(embed=embed)
项目:KeekoBot    作者:DavidNeon    | 项目源码 | 文件源码
def join(self,so I must be invited with an OAuth2"
                   " link:\nFor more information: "
                   "---"
                   "---")
            await self.bot.say(msg)
            if hasattr(self.bot, 'oauth_url'):
                await self.bot.whisper("Here's my OAUTH2 link:\n{}".format(
                    self.bot.oauth_url))
            return

        if invite_url is None:
            await self.bot.say("I need a discord Invite link for the "
                               "server you want me to join.")
            return

        try:
            await self.bot.accept_invite(invite_url)
            await self.bot.say("Server joined.")
            log.debug("We just joined {}".format(invite_url))
        except discord.NotFound:
            await self.bot.say("The invite was invalid or expired.")
        except discord.HTTPException:
            await self.bot.say("I wasn't able to accept the invite."
                               " Try again.")

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐