当前位置: 首页>>代码示例>>Python>>正文


Python discord.VoiceChannel方法代码示例

本文整理汇总了Python中discord.VoiceChannel方法的典型用法代码示例。如果您正苦于以下问题:Python discord.VoiceChannel方法的具体用法?Python discord.VoiceChannel怎么用?Python discord.VoiceChannel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在discord的用法示例。


在下文中一共展示了discord.VoiceChannel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: connect

# 需要导入模块: import discord [as 别名]
# 或者: from discord import VoiceChannel [as 别名]
def connect(self, channel):
		if not isinstance(channel, discord.VoiceChannel):
			channel = self.bot.get_channel(channel)

		voice = self.voice

		if voice is None:
			print(f"attempting connect to: {channel.id}")
			await channel.connect()
			print(f"finished connect to: {channel.id}")
		elif voice.channel and voice.channel.id == channel.id:
			print(f"doin a disconnect and reconnect for: {channel.id}")
			await voice.disconnect(force=True)
			await asyncio.sleep(1)
			await channel.connect()
			print(f"finished reconnect for: {channel.id}")
			# print(f"leaving this because we're supposedly already connected? ({channel.id})")
		else:
			print(f"attempting move to: {channel.id}")
			await voice.move_to(channel)
			print(f"finished move to: {channel.id}") 
开发者ID:mdiller,项目名称:MangoByte,代码行数:23,代码来源:audio.py

示例2: on_guild_channel_delete

# 需要导入模块: import discord [as 别名]
# 或者: from discord import VoiceChannel [as 别名]
def on_guild_channel_delete(self, channel: GUILD_CHANNEL) -> None:
        """Log channel delete event to mod log."""
        if channel.guild.id != GuildConstant.id:
            return

        if isinstance(channel, discord.CategoryChannel):
            title = "Category deleted"
        elif isinstance(channel, discord.VoiceChannel):
            title = "Voice channel deleted"
        else:
            title = "Text channel deleted"

        if channel.category and not isinstance(channel, discord.CategoryChannel):
            message = f"{channel.category}/{channel.name} (`{channel.id}`)"
        else:
            message = f"{channel.name} (`{channel.id}`)"

        await self.send_log_message(
            Icons.hash_red, Colours.soft_red,
            title, message
        ) 
开发者ID:python-discord,项目名称:bot,代码行数:23,代码来源:modlog.py

示例3: on_guild_channel_create

# 需要导入模块: import discord [as 别名]
# 或者: from discord import VoiceChannel [as 别名]
def on_guild_channel_create(self, channel: GUILD_CHANNEL) -> None:
        """Log channel create event to mod log."""
        if channel.guild.id != GuildConstant.id:
            return

        if isinstance(channel, discord.CategoryChannel):
            title = "Category created"
            message = f"{channel.name} (`{channel.id}`)"
        elif isinstance(channel, discord.VoiceChannel):
            title = "Voice channel created"

            if channel.category:
                message = f"{channel.category}/{channel.name} (`{channel.id}`)"
            else:
                message = f"{channel.name} (`{channel.id}`)"
        else:
            title = "Text channel created"

            if channel.category:
                message = f"{channel.category}/{channel.name} (`{channel.id}`)"
            else:
                message = f"{channel.name} (`{channel.id}`)"

        await self.send_log_message(Icons.hash_green, Colours.soft_green, title, message) 
开发者ID:python-discord,项目名称:bot,代码行数:26,代码来源:modlog.py

示例4: convert

# 需要导入模块: import discord [as 别名]
# 或者: from discord import VoiceChannel [as 别名]
def convert(self, ctx, argument):
        bot = ctx.bot
        match = self._get_id_match(argument) or re.match(r'<#([0-9]+)>$', argument)
        result = None
        guild = ctx.guild

        if match is None:
            # not a mention
            if guild:
                result = discord.utils.get(guild.voice_channels, name=argument)
            else:
                def check(c):
                    return isinstance(c, discord.VoiceChannel) and c.name == argument
                result = discord.utils.find(check, bot.get_all_channels())
        else:
            channel_id = int(match.group(1))
            if guild:
                result = guild.get_channel(channel_id)
            else:
                result = _get_from_guilds(bot, 'get_channel', channel_id)

        if not isinstance(result, discord.VoiceChannel):
            raise BadArgument('Channel "{}" not found.'.format(argument))

        return result 
开发者ID:Rapptz,项目名称:discord.py,代码行数:27,代码来源:converter.py

示例5: mute

# 需要导入模块: import discord [as 别名]
# 或者: from discord import VoiceChannel [as 别名]
def mute(self, ctx, user: discord.Member, time: int=15):
        '''Mute a member in the guild'''
        secs = time * 60
        for channel in ctx.guild.channels:
            if isinstance(channel, discord.TextChannel):
                await ctx.channel.set_permissions(user, send_messages=False)
            elif isinstance(channel, discord.VoiceChannel):
                await channel.set_permissions(user, connect=False)
        await ctx.send(f"{user.mention} has been muted for {time} minutes.")
        await asyncio.sleep(secs)
        for channel in ctx.guild.channels:
            if isinstance(channel, discord.TextChannel):
                await ctx.channel.set_permissions(user, send_messages=None)
            elif isinstance(channel, discord.VoiceChannel):
                await channel.set_permissions(user, connect=None)
        await ctx.send(f'{user.mention} has been unmuted from the guild.') 
开发者ID:cree-py,项目名称:RemixBot,代码行数:18,代码来源:mod.py

示例6: channel_bitrate

# 需要导入模块: import discord [as 别名]
# 或者: from discord import VoiceChannel [as 别名]
def channel_bitrate(
        self, ctx: commands.Context, channel: discord.VoiceChannel, bitrate: int
    ) -> None:
        """Edit a voice channels bitrate"""
        try:
            await channel.edit(
                bitrate=bitrate, reason=_("Requested by {author}").format(author=ctx.author)
            )
        except Exception:
            await ctx.send(
                _(
                    "`{bitrate}` is either too high or too low please "
                    "provide a number between 8000 and 96000."
                ).format(bitrate=bitrate)
            )
            return
        await ctx.tick() 
开发者ID:TrustyJAID,项目名称:Trusty-cogs,代码行数:19,代码来源:serverstats.py

示例7: channel_userlimit

# 需要导入模块: import discord [as 别名]
# 或者: from discord import VoiceChannel [as 别名]
def channel_userlimit(
        self, ctx: commands.Context, channel: discord.VoiceChannel, limit: int
    ) -> None:
        """Edit a voice channels user limit"""
        try:
            await channel.edit(
                user_limit=limit, reason=_("Requested by {author}").format(author=ctx.author)
            )
        except Exception:
            await ctx.send(
                _(
                    "`{limit}` is either too high or too low please "
                    "provide a number between 0 and 99."
                ).format(limit=limit)
            )
            return
        await ctx.tick() 
开发者ID:TrustyJAID,项目名称:Trusty-cogs,代码行数:19,代码来源:serverstats.py

示例8: convert

# 需要导入模块: import discord [as 别名]
# 或者: from discord import VoiceChannel [as 别名]
def convert(
        self, ctx: commands.Context, argument: str
    ) -> Union[discord.TextChannel, discord.CategoryChannel, discord.VoiceChannel]:
        match = self._get_id_match(argument) or re.match(r"<#([0-9]+)>$", argument)
        result = None
        guild = ctx.guild

        if match is None:
            # not a mention
            result = discord.utils.get(guild.channels, name=argument)

        else:
            channel_id = int(match.group(1))
            result = guild.get_channel(channel_id)

        if not result:
            raise BadArgument(f"Channel `{argument}` not found")
        return result 
开发者ID:TrustyJAID,项目名称:Trusty-cogs,代码行数:20,代码来源:converters.py

示例9: ignore

# 需要导入模块: import discord [as 别名]
# 或者: from discord import VoiceChannel [as 别名]
def ignore(
        self,
        ctx: commands.Context,
        channel: Union[discord.TextChannel, discord.CategoryChannel, discord.VoiceChannel],
    ) -> None:
        """
            Ignore a channel from message delete/edit events and bot commands

            `channel` the channel or category to ignore events in
        """
        if ctx.guild.id not in self.settings:
            self.settings[ctx.guild.id] = inv_settings
        guild = ctx.message.guild
        if channel is None:
            channel = ctx.channel
        cur_ignored = await self.config.guild(guild).ignored_channels()
        if channel.id not in cur_ignored:
            cur_ignored.append(channel.id)
            await self.config.guild(guild).ignored_channels.set(cur_ignored)
            self.settings[guild.id]["ignored_channels"] = cur_ignored
            await ctx.send(_(" Now ignoring events in ") + channel.mention)
        else:
            await ctx.send(channel.mention + _(" is already being ignored.")) 
开发者ID:TrustyJAID,项目名称:Trusty-cogs,代码行数:25,代码来源:extendedmodlog.py

示例10: join

# 需要导入模块: import discord [as 别名]
# 或者: from discord import VoiceChannel [as 别名]
def join(self, ctx, *, channel: discord.VoiceChannel):
        """Joins a voice channel"""

        if ctx.voice_client is not None:
            return await ctx.voice_client.move_to(channel)

        await channel.connect() 
开发者ID:Rapptz,项目名称:discord.py,代码行数:9,代码来源:basic_voice.py

示例11: unmute

# 需要导入模块: import discord [as 别名]
# 或者: from discord import VoiceChannel [as 别名]
def unmute(self, ctx, user: discord.Member):
        '''Unmute a member in the guild'''
        for channel in ctx.guild.channels:
            if isinstance(channel, discord.TextChannel):
                await ctx.channel.set_permissions(user, send_messages=None)
            elif isinstance(channel, discord.VoiceChannel):
                await channel.set_permissions(user, connect=None)
        await ctx.send(f'{user.mention} has been unmuted from the guild.') 
开发者ID:cree-py,项目名称:RemixBot,代码行数:10,代码来源:mod.py

示例12: init_channels

# 需要导入模块: import discord [as 别名]
# 或者: from discord import VoiceChannel [as 别名]
def init_channels(self):
		await self.bot.wait_until_ready()
		if self.configured.is_set():
			return

		for channel_id, settings in self.bot.config['logs'].items():
			channel = self.bot.get_channel(channel_id)
			if channel is None:
				logger.warning(f'Configured logging channel ID {channel_id} was not found!')
			if isinstance(channel, discord.VoiceChannel):
				logger.warning(f'Voice channel {channel!r} was configured as a logging channel!')
				continue
			self.channels[channel] = settings

		self.configured.set() 
开发者ID:EmoteBot,项目名称:EmoteCollector,代码行数:17,代码来源:logging.py

示例13: get_voice_client

# 需要导入模块: import discord [as 别名]
# 或者: from discord import VoiceChannel [as 别名]
def get_voice_client(self, channel: discord.abc.GuildChannel):
        if isinstance(channel, discord.Object):
            channel = self.get_channel(channel.id)

        if not isinstance(channel, discord.VoiceChannel):
            raise AttributeError('Channel passed must be a voice channel')

        if channel.guild.voice_client:
            return channel.guild.voice_client
        else:
            return await channel.connect(timeout=60, reconnect=True) 
开发者ID:helionmusic,项目名称:rhinobot_heroku,代码行数:13,代码来源:bot.py

示例14: getperms

# 需要导入模块: import discord [as 别名]
# 或者: from discord import VoiceChannel [as 别名]
def getperms(self, member: discord.Member, channel: typing.Union[discord.TextChannel, discord.VoiceChannel, discord.CategoryChannel]):
		perms = []
		for perm, value in member.permissions_in(channel):
			if value:
				perms.append(perm)
		return perms 
开发者ID:FireDiscordBot,项目名称:bot,代码行数:8,代码来源:utils.py

示例15: jsk_vc_join

# 需要导入模块: import discord [as 别名]
# 或者: from discord import VoiceChannel [as 别名]
def jsk_vc_join(self, ctx: commands.Context, *,
                          destination: typing.Union[discord.VoiceChannel, discord.Member] = None):
        """
        Joins a voice channel, or moves to it if already connected.

        Passing a voice channel uses that voice channel.
        Passing a member will use that member's current voice channel.
        Passing nothing will use the author's voice channel.
        """

        if await vc_check(ctx):
            return

        destination = destination or ctx.author

        if isinstance(destination, discord.Member):
            if destination.voice and destination.voice.channel:
                destination = destination.voice.channel
            else:
                return await ctx.send("Member has no voice channel.")

        voice = ctx.guild.voice_client

        if voice:
            await voice.move_to(destination)
        else:
            await destination.connect(reconnect=True)

        await ctx.send(f"Connected to {destination.name}.") 
开发者ID:Gorialis,项目名称:jishaku,代码行数:31,代码来源:cog_base.py


注:本文中的discord.VoiceChannel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。