def _set_channel_cmd(self, msg):
args = shlex.split(msg.content)
if len(args) > 1:
chantype = args[1].lower()
else:
raise CommandSyntaxError("No channel type provided.")
if len(args) > 2:
if chantype.startswith("voice"):
channel = args[2].lower()
channel = utils.find(lambda x: isinstance(x, VoiceChannel) and x.name.lower() == channel,
msg.guild.channels)
if not channel:
raise CommandSyntaxError(f"Voice channel {args[2].lower()} not found.")
else:
if msg.channel_mentions:
channel = msg.channel_mentions[0]
else:
raise CommandSyntaxError("No channel provided.")
else:
channel = None
self.channel_manager.set_channel(msg.guild, chantype, channel)
if channel:
await respond(msg, f"**ANALYSIS: The {chantype} channel for this server has been set to "
f"{channel.mention}.**")
else:
await respond(msg, f"ANALYSIS: The {chantype} channel for this server has been disabled.")
评论列表
文章目录