async def unmute_handler(self, ctx, error): if isinstance(error, commands.errors.MissingPermissions): await ctx.reply( get_language_str(ctx.guild.id, 28).format(ctx.author.name, error)) return if isinstance(error, commands.errors.MissingRequiredArgument): if error.param.name == 'user': await ctx.reply( get_language_str(ctx.guild.id, 96).format(ctx.author.name, error)) return
async def poprule_command(self, ctx, rulekey): rulefile = f'data/servers/{ctx.guild.id}/rules.json' if not os.path.exists(rulefile): await ctx.reply(get_language_str(ctx.guild.id, 70)) return try: pop_rule(ctx.guild.id, rulekey) except KeyError: await ctx.reply(get_language_str(ctx.guild.id, 71)) return await ctx.reply(get_language_str(ctx.guild.id, 72))
async def addrule_command(self, ctx, rulekey): def check(ms): return ms.channel == ctx.message.channel and ms.author == ctx.message.author await ctx.send(get_language_str(ctx.guild.id, 68)) replymsg = await self.bot.wait_for('message', check=check) rulevalue = replymsg.content try: set_rule(ctx.guild.id, rulekey, rulevalue) except BrokenRulesError: await ctx.reply(get_language_str(ctx.guild.id, 123)) return await ctx.reply(get_language_str(ctx.guild.id, 69))
async def storepins_command(self, ctx, channel: discord.TextChannel): pins = await ctx.channel.pins() if not pins: await ctx.reply(get_language_str(ctx.guild.id, 135)) return msg = await ctx.send(get_language_str(ctx.guild.id, 136)) delete_pins = await wait_for_user(ctx, self.bot, msg, False) await msg.delete() do_sleep = False pins = reversed(pins) for pin in pins: if do_sleep: await asyncio.sleep(5) embed = discord.Embed( title=f"Pinned message in #{pin.channel.name}", description=pin.content, color=random.choice(color_list), url=pin.jump_url, timestamp=pin.created_at) send_video = "" if pin.attachments: file_type = get_file_type(pin.attachments[0]) if file_type == 1: embed.set_image(url=pin.attachments[0].url) elif file_type == 2: send_video = f'{pin.attachments[0].url} ' \ f'**(putting this attachment link here so that the video can load, ' \ f'since Discord currently does not allow videos inside bot embeds)**' if len(pin.attachments) > 1 or file_type != 1: attachments = "" for attachment in pin.attachments: # attachments += attachment.url + '\n' file_type = get_file_type(attachment) attachments += f"[{attachment.filename} ({attachment.content_type})]" \ f"({attachment.url})\n" if file_type == 2: attachments += "**The attached video has been sent as a separate message!**" embed.add_field(name='Attachments', value=attachments) embed.set_author(name=pin.author.name, icon_url=pin.author.avatar_url, url=f"https://discord.com/users/{pin.author.id}/") await channel.send(embed=embed) if send_video: await ctx.send(content=send_video) if delete_pins: await pin.delete() do_sleep = True await channel.send("`--- end of pins ---`") await ctx.reply('Done storing pins.')
async def protondb_command(self, ctx, *, requested_app="220"): if requested_app.isdigit(): app_id = requested_app else: try: app_id = (await search_game(requested_app))[0] except IndexError: await ctx.reply(get_language_str(ctx.guild.id, 132)) return try: received = await get_protondb_summary(app_id) except GameNotFound: await ctx.reply(get_language_str(ctx.guild.id, 133)) return tier = received.get("tier").title() string_result = received.get("string_result") game_data = (await get_steam_app_info(app_id))[str(app_id)]["data"] if check_if_steam_nsfw(ctx, game_data): # f**k my server forcing me to do this to make them shut up game_name = "Unnamed NSFW game" game_image = \ "https://upload.wikimedia.org/wikipedia/commons/thumb/9/91/Snake_plant.jpg/1200px-Snake_plant.jpg" game_url = "" else: game_name = game_data["name"] game_image = game_data["header_image"] game_url = f"https://www.protondb.com/app/{app_id}" color = received.get("tier_color") if game_data["platforms"]["linux"]: string_result = string_result + '\n\n' + get_language_str(ctx.guild.id, 134) # await ctx.reply(string_result) # await ctx.send(f"Game's {game_name} by the way, here's an image: {game_image}") embed = discord.Embed( title=game_name, description=f"**{tier}**\n{string_result}", url=game_url, color=color ) embed.set_footer( text="ProtonDB", icon_url="https://www.protondb.com/sites/protondb/images/favicon.ico" ) embed.set_thumbnail( url=game_image ) await ctx.reply(embed=embed)
async def lyrics_command(self, ctx, *, query=None): if not query: # check if user playing something on spotefiye # discord when will you add support for tidal /s if not ctx.guild: await ctx.send("I can't retrieve your user activity inside private messages, " "so you'll have to manually insert them.") return user_listening = get_listening_to(ctx.author.activities) if user_listening: parenthesis_regex = re.compile(r' \(.*?\)') query = f"{parenthesis_regex.sub('', user_listening[0]).split(' - ')[0]} - {user_listening[-1]}" # string spaghetti else: await ctx.reply(get_language_str(ctx.guild.id, 19)) return msg = await ctx.send(f'Searching for "{query}"') song = await lyrics(query) if not song: song = Lyrics() thumbnail = song.thumbnail url = song.url title = song.title artist = song.artist if len(song.lyrics) >= 4096: lyric_str = ''.join(list(song.lyrics)[:4093]) + '...' # Apparently Discord upgraded their character limit. else: # Haven't had much issues yet. lyric_str = song.lyrics embed = discord.Embed( title=get_language_str(ctx.guild.id, 20).format(title, artist), description=lyric_str, color=random.choice(color_list) ) if url: embed.url = url if thumbnail: embed.set_thumbnail(url=thumbnail) embed.set_author( name=ctx.message.author.name, icon_url=ctx.message.author.avatar_url, url=f"https://discord.com/users/{ctx.message.author.id}/" ) embed.set_footer( text=song.source, icon_url=song.source_icon ) await ctx.reply(embed=embed) await msg.delete()
async def check_message(message): result = check_banword_filter(message.content, message.guild.id) penalty = result[0] if penalty != 0: try: await message.delete() except discord.errors.NotFound: pass # oh well. if penalty != 1: try: offensive_word = result[1] do_warn = result[2] if penalty == 2: # ban await message.author.ban( reason=f'Banned for saying word {offensive_word}\n' f'Full message: {message.content}') if penalty == 3: # kick await message.author.kick( reason=f'Kicked for saying word {offensive_word}\n' f'Full message: {message.content}') if penalty == 4: # mute role = message.guild.get_role( get_server_config(message.guild.id, 'mute_role', int)) await message.author.add_roles(role) mute.add_mutes(message.guild.id, role.id, message.author.id, bot.user.id, "1 hour") if do_warn: # warn moderation.warn( message.guild.id, message.author.id, bot.user.id, bot.user.name, message.channel.id, f'Warned for saying word {offensive_word}\n' f'Full message: {message.content}') except discord.errors.Forbidden: await message.channel.send( get_language_str(message.guild.id, 5))
async def warns_command(self, ctx, *, user: discord.Member): warn_data = get_warns(ctx.guild.id, user.id) if not warn_data: await ctx.reply(get_language_str(ctx.guild.id, 114)) return # If the script made it this far, then the user has warns. warns = warn_data warn_amount = len(warns) username = user.name embed = discord.Embed( title=f"{username}'s warns", description= f"They have {warn_amount} {'warn' if warn_amount == 1 else 'warns'}.", color=random.choice(color_list)) embed.set_author( name=ctx.message.author.name, icon_url=ctx.message.author.avatar_url, url=f"https://discord.com/users/{ctx.message.author.id}/") for index, warn_thing in enumerate(warns): embed.add_field( name=f"Warn {index + 1}", # value=f"Warner: {warner_display}\n" # f"Channel: <#{warn_channel}>\n" # f"Date and Time: {warn_datetime}\n" # f"Reason:```\n{warn_reason}\n```", value=format_warn(warn_thing, self.bot), inline=False) await ctx.reply(content=None, embed=embed)
async def search_command(self, ctx, *, to_search): response = await search(to_search) if response is not None: embed = discord.Embed( title=response['title'], description=response['description'], url=response['url'] ) embed.set_footer( text=response['source'] ) if response['image']: embed.set_thumbnail( url=response['image'] ) if ctx.guild: limit = 6 else: limit = None for field in response['fields'][:limit]: embed.add_field( name=field['name'], value=field['value'] + (('\n' + f"**[Link]({field['url']})**") if field['url'] else ""), # Behold: big f*****g nonsense! inline=True ) if response['engine']: embed.set_footer( text=response['engine'], icon_url=response['engine_icon'] ) await ctx.send(embed=embed) else: await ctx.reply(get_language_str(ctx.guild.id, 122))
async def tempban_command(self, ctx, users: commands.Greedy[discord.Member], *, timestamp): if not users: await ctx.reply( get_language_str(ctx.guild.id, 90).format(ctx.author.name, "No users specified.")) return for user in users: str_dt_obj = add_bans(ctx.guild.id, user.id, ctx.author.id, timestamp) await user.ban( reason= f"Banned by {ctx.author.name}, will be unbanned at: {str_dt_obj}" ) embed = discord.Embed( title="User temp-banned", description=f"User: **{user}**\n" f"Time until the user will be unbanned: **{str_dt_obj}**\n" f"Banned by: **{ctx.author}**", color=random.choice(color_list)) embed.set_thumbnail(url=user.avatar_url) embed.set_author( name=ctx.message.author.name, icon_url=ctx.message.author.avatar_url, url=f"https://discord.com/users/{ctx.message.author.id}/") await ctx.reply(embed=embed)
async def storepins_handler(self, ctx, error): if isinstance(error, commands.MissingRequiredArgument): if error.param.name == 'channel': await ctx.reply( get_language_str(ctx.guild.id, 84).format(ctx.message.author.name)) return
async def warn_handler(self, ctx, error): if isinstance(error, commands.MissingPermissions): await ctx.reply(get_language_str(ctx.guild.id, 192)) return if isinstance(error, commands.MissingRequiredArgument): if error.param.name == 'user': await ctx.reply( get_language_str(ctx.guild.id, 111).format(ctx.author.name)) return if isinstance(error, commands.MissingRequiredArgument): if error.param.name == 'reason': await ctx.reply( get_language_str(ctx.guild.id, 112).format(ctx.author.name)) return
async def kick_handler(self, ctx, error): if isinstance(error, commands.MemberNotFound): await ctx.reply(f'{error} *(Action cancelled.)*') return elif isinstance(error, commands.MissingRequiredArgument): if error.param.name == 'user': await ctx.reply(get_language_str(ctx.guild.id, 76)) return
async def edit_warn_command(self, ctx, user: discord.Member, *, warn_index: str): def check(ms): # Look for the message sent in the same channel where the command was used # As well as by the user who used the command. return ms.channel == ctx.message.channel and ms.author == ctx.message.author warnindex = int(warn_index) - 1 if warnindex < 0: await ctx.reply(get_language_str(ctx.guild.id, 115)) return try: specified_warn = get_warn(ctx.guild.id, user.id, warnindex) except IndexError: await ctx.reply(get_language_str(ctx.guild.id, 115)) return await ctx.send(content=get_language_str(ctx.guild.id, 119)) msg = await self.bot.wait_for('message', check=check) warn_new_reason = msg.content specified_warn.reason = warn_new_reason confirmation_embed = discord.Embed( title=f'{user.name}\'s warn number {warn_index}', # description=f'Warner: {warn_warner_name}\n' # f'Reason: {warn_new_reason}\n' # f'Channel: <#{warn_channel}>\n' # f'Date and Time: {warn_datetime}', description=format_warn(specified_warn, self.bot), color=random.choice(color_list), ) confirmation_embed.set_author( name=ctx.message.author.name, icon_url=ctx.message.author.avatar_url, url=f"https://discord.com/users/{ctx.message.author.id}/") msg = await ctx.send(content=get_language_str(ctx.guild.id, 120), embed=confirmation_embed) if await wait_for_user(ctx, self.bot, msg): edit_warn(ctx.guild.id, user.id, int(warnindex), warn_new_reason) await ctx.reply(get_language_str(ctx.guild.id, 121)) return
async def unmute_command(self, ctx, users: commands.Greedy[discord.Member]): for user in users: mute_role_id = unmute_user(ctx.guild.id, user.id) # seems messy but unmute_user() not only returns the mute role's ID but also deletes all mute data for # specified user mute_role = discord.utils.get(ctx.guild.roles, id=mute_role_id) await user.remove_roles(mute_role) await ctx.reply(get_language_str(ctx.guild.id, 95))
async def on_message(message): if message.guild: await check_message(message) if message.author.id == bot.user.id: return # To prevent the bot itself from triggering things. if message.author.id in excluded_users: return global message_count if message.guild and get_server_config(message.guild.id, 'inactivity_func', bool) and \ message.channel.id in get_server_config(message.guild.id, 'inactivity_channels', list): if message.channel.id in message_count: count = message_count[message.channel.id] else: count = 0 message_count[message.channel.id] = count + 1 if (message.content == bot_mention) or (message.content == bot_mention_mobile): if message.author.id not in get_server_config(message.guild.id, 'asked_prefix', list): # remind user about the prefix asked = get_server_config(message.guild.id, 'asked_prefix', list) asked.append(message.author.id) write_server_config(message.guild.id, 'asked_prefix', asked) await message.channel.send( get_language_str(message.guild.id, 4).format( get_server_config(message.guild.id, 'prefix', str))) else: # taunt the user to_send = get_language_str( get_server_config(message.guild.id, 'language', str), 0) await message.channel.send(random.choice(to_send).format(message)) return if '(╯°□°)╯︵ ┻━┻' in message.content and message.guild: if get_server_config(message.guild.id, 'tableflip', bool): async with message.channel.typing(): lang = get_server_config(message.guild.id, 'language', str) to_send = get_language_str(lang, 2) to_send = random.choice(to_send) await asyncio.sleep(0.75) await message.channel.send(to_send.format(message))
async def temp_ban_status_handler(self, ctx, error): if isinstance(error, commands.errors.MissingPermissions): await ctx.reply( get_language_str(ctx.guild.id, 28).format(ctx.author.name, error)) return if isinstance(error, commands.errors.MissingRequiredArgument): if error.param.name == 'user': await ctx.reply( f'{ctx.author.name}, you did not specify a user. ' f'*({error} Action cancelled)*') return
async def say_command(self, ctx, *, repeat=None): # Next, we check if the user actually passed some text if not repeat: await ctx.reply(get_language_str(ctx.guild.id, 11)) return elif repeat == "** **": await ctx.reply(f"** **... ***{get_language_str(ctx.guild.id, 11)}***") elif "@everyone" in repeat or "@here" in repeat: await ctx.reply("**No.**") else: await ctx.send(repeat)
async def remove_warn_command(self, ctx, user: discord.Member, *, warn_index: int): warn_index = int(warn_index) - 1 specified_warn = get_warn(ctx.guild.id, user.id, warn_index) confirmation_embed = discord.Embed( title=f'{user.name}\'s warn number {warn_index + 1}', description=format_warn(specified_warn, self.bot), color=random.choice(color_list), ) confirmation_embed.set_author( name=ctx.message.author.name, icon_url=ctx.message.author.avatar_url, url=f"https://discord.com/users/{ctx.message.author.id}/") msg = await ctx.send(content=get_language_str(ctx.guild.id, 116), embed=confirmation_embed) if await wait_for_user(ctx, self.bot, msg): remove_warn(ctx.guild.id, user.id, warn_index) await ctx.reply(get_language_str(ctx.guild.id, 117)) return
async def owofy_command(self, ctx): def check(ms): return ms.channel == ctx.message.channel and ms.author == ctx.message.author msg = ctx.message.content prefix_used = ctx.prefix alias_used = ctx.invoked_with text = msg[len(prefix_used) + len(alias_used):] # Next, we check if the user actually passed some text if text == '': # User didn't specify the text, which means we'll have to ask for it. await ctx.send(get_language_str(ctx.guild.id, 12)) msg = await self.bot.wait_for('message', check=check) text = msg.content pass text = owofy(text) if not len(text) < 2000: await ctx.send(get_language_str(ctx.guild.id, 13).format(len(text))) return await ctx.reply(text) # the pain has been done.
async def mutestatus_command(self, ctx, users: commands.Greedy[discord.Member]): if not users: await ctx.reply( get_language_str(ctx.guild.id, 126).format(ctx.author.name)) for user in users: try: user_mute = get_mute_status(ctx.guild.id, user.id) except NoMutesForGuild: await ctx.reply(get_language_str(ctx.guild.id, 92)) return except NoMutesForUser: await ctx.reply( get_language_str(ctx.guild.id, 93).format(user.name)) return # user has been muted. mute_time = user_mute.unmute_time muter_id = user_mute.mute_author_id muter = ctx.guild.get_member(muter_id) # mute_index = user_mute.index # mute_data = user_mute.mute_data # mute_role_id = user_mute.role_id # mute_role = discord.utils.get(ctx.guild.roles, id=mute_role_id) embed = discord.Embed( title=f"{user}'s mute status", description= f"Time until the user will be unmuted: **{mute_time}**\n" f"Muted by: **{muter}**", color=random.choice(color_list)) embed.set_thumbnail(url=user.avatar_url) embed.set_author( name=ctx.message.author.name, icon_url=ctx.message.author.avatar_url, url=f"https://discord.com/users/{ctx.message.author.id}/") await ctx.reply(embed=embed)
async def embed_command(self, ctx): def check(ms): return ms.channel == ctx.message.channel and ms.author == ctx.message.author await ctx.send(get_language_str(ctx.guild.id, 14)) # Wait for a response and get the title msg = await self.bot.wait_for('message', check=check) if len(msg.content) < 257: # Checks if title's length is bigger than 256. title = msg.content else: await ctx.send(get_language_str(ctx.guild.id, 15).format(len(msg.content))) return # Next, ask for the content await ctx.send(get_language_str(ctx.guild.id, 16)) msg = await self.bot.wait_for('message', check=check) desc = msg.content # For some reason bot embed descriptions have no limits. # https://cdn.discordapp.com/attachments/661616167378485249/780232830180655155/unknown.png # Finally make the embed and send it msg = await ctx.reply(content='Now generating the embed...') embed = discord.Embed( title=title, description=desc, color=random.choice(color_list) ) embed.set_thumbnail(url=self.bot.user.avatar_url) embed.set_author( name=ctx.message.author.name, icon_url=ctx.message.author.avatar_url, url=f"https://discord.com/users/{ctx.message.author.id}/" ) await msg.edit( embed=embed, content=None )
async def rules_command(self, ctx, rule: str): try: rule_desc = get_rules(ctx.guild.id).get(rule.lower()) except NoRulesError: await ctx.reply(get_language_str(ctx.guild.id, 65)) return except BrokenRulesError: await ctx.reply(get_language_str(ctx.guild.id, 123)) return if not rule_desc: await ctx.reply( get_language_str(ctx.guild.id, 66).format(ctx.message.author.name)) return embed = discord.Embed(title=f"Rule {rule.lower()}", description=f"{rule_desc}", color=random.choice(color_list)) embed.set_author( name=ctx.message.author.name, icon_url=ctx.message.author.avatar_url, url=f"https://discord.com/users/{ctx.message.author.id}/") await ctx.reply(embed=embed, content=None)
async def purge_command(self, ctx, to_delete=5): if to_delete <= 0: await ctx.reply(get_language_str(ctx.guild.id, 62)) return do_purge = True if to_delete >= 10: msg = await ctx.send( get_language_str(ctx.guild.id, 63).format(ctx.author.name, str(to_delete))) do_purge = await wait_for_user(ctx, self.bot, msg) await msg.delete() await ctx.message.delete() if do_purge: try: await ctx.channel.purge(limit=to_delete) except discord.NotFound: pass temp_message = await ctx.send( get_language_str(ctx.guild.id, 64).format(ctx.author.name, str(to_delete))) await asyncio.sleep(5) await temp_message.delete() return
async def mute_command(self, ctx, users: commands.Greedy[discord.Member], *, timestamp): if get_server_config(ctx.guild.id, 'mute_role', int) == 0: await ctx.reply(get_language_str(ctx.guild.id, 85)) return role = ctx.guild.get_role( get_server_config(ctx.guild.id, 'mute_role', int)) if not users: await ctx.reply( get_language_str(ctx.guild.id, 90).format(ctx.author.name, "No users specified.")) return for user in users: if role in user.roles: await ctx.reply( get_language_str(ctx.guild.id, 86).format(ctx.author.name)) return else: pass await user.add_roles(role) try: str_dt_obj = add_mutes(ctx.guild.id, role.id, user.id, ctx.author.id, timestamp) except InvalidTimeParsed: await ctx.send(get_language_str(ctx.guild.id, 87)) return except PastTimeError: await ctx.send(get_language_str(ctx.guild.id, 88)) return except PresentTimeError: await ctx.send(get_language_str(ctx.guild.id, 89)) return embed = discord.Embed( title="User muted", description=f"User: **{user}**\n" f"Time until the user will be unmuted: **{str_dt_obj}**\n" f"Muted by: **{ctx.author}**", color=random.choice(color_list)) embed.set_thumbnail(url=user.avatar_url) embed.set_author( name=ctx.message.author.name, icon_url=ctx.message.author.avatar_url, url=f"https://discord.com/users/{ctx.message.author.id}/") await ctx.reply(embed=embed)
async def changelang_command(self, ctx, *, commandargs=None): # NOTICE: DO NOT TRANSLATE THIS COMMAND! def check(ms): return ms.channel == ctx.message.channel and ms.author == ctx.message.author if not commandargs: await ctx.send("What would you like to change the language to?") msg = await self.bot.wait_for('message', check=check) commandargs = msg.content else: commandargs = commandargs.replace(' ', '') commandargs = commandargs.lower() if commandargs in get_all_languages(): # language exists write_server_config(ctx.guild.id, 'language', commandargs) await ctx.reply( get_language_str(commandargs, 4).format( get_server_config(ctx.guild.id, 'prefix', str))) else: # me no tabla whatever the hell kind of language they want to tell me await ctx.reply("Could not find that language, no changes made.")
async def mutedrole_command(self, ctx): def check(ms): return ms.channel == ctx.message.channel and ms.author == ctx.message.author commandmsg = ctx.message.content prefix_used = ctx.prefix alias_used = ctx.invoked_with commandargs = commandmsg[len(prefix_used) + len(alias_used):] # Next, we check if the user actually passed some text if commandargs == '': await ctx.send(get_language_str(ctx.guild.id, 41)) msg = await self.bot.wait_for('message', check=check) new_role = msg.content else: new_role = commandargs replace = {' ': '', '<': '', '@': '', '&': '', '>': ''} for key, value in replace.items(): new_role = new_role.replace(key, value) if new_role.isdigit(): role = ctx.guild.get_role(int(new_role)) if role is None: await ctx.reply(get_language_str(ctx.guild.id, 42)) return else: role = discord.utils.get(ctx.guild.roles, name=new_role) if role is None: await ctx.reply(get_language_str(ctx.guild.id, 43)) return # Checks if role is already the one that's already defined. If not, ask for confirmation if role.id == get_server_config(ctx.guild.id, 'mute_role', int): await ctx.send(get_language_str(ctx.guild.id, 44)) return else: msg = await ctx.send( get_language_str(ctx.guild.id, 45).format(role.name)) if await wait_for_user(ctx, self.bot, msg): write_server_config(ctx.guild.id, 'mute_role', role.id) await ctx.reply( get_language_str(ctx.guild.id, 46).format(role.name)) return
async def toggleinactivity_handler(self, ctx, error): if isinstance(error, commands.errors.MissingPermissions): await ctx.reply( get_language_str(ctx.guild.id, 28).format(ctx.author.name, error)) return
async def disablecmd_handler(self, ctx, error): if isinstance(error, commands.errors.MissingPermissions): await ctx.send( get_language_str(ctx.guild.id, 28).format(ctx.author.name, error)) return
async def inactivitychannel_command(self, ctx): def check(ms): return ms.channel == ctx.message.channel and ms.author == ctx.message.author command_msg = ctx.message.content prefix_used = ctx.prefix alias_used = ctx.invoked_with command_args = command_msg[len(prefix_used) + len(alias_used):] # Next, we check if the user actually passed some text if command_args == '': await ctx.send(get_language_str(ctx.guild.id, 34)) msg = await self.bot.wait_for('message', check=check) new_channel = msg.content else: new_channel = command_args replace = {' ': '', '<': '', '#': '', '>': ''} for key, value in replace.items(): new_channel = new_channel.replace(key, value) if new_channel.isdigit(): channel = ctx.guild.get_channel(int(new_channel)) if channel is None: await ctx.reply(get_language_str(ctx.guild.id, 35)) return else: channel = discord.utils.get(self.bot.get_all_channels(), guild=ctx.guild, name=new_channel) if channel is None: await ctx.reply(get_language_str(ctx.guild.id, 36)) return # Ask the user for confirmation if channel.id in get_server_config(ctx.guild.id, 'inactivity_channels', list): msg = await ctx.send( get_language_str(ctx.guild.id, 37).format(channel.id)) remove = True else: msg = await ctx.send( get_language_str(ctx.guild.id, 38).format(channel.id)) remove = False if await wait_for_user(ctx, self.bot, msg): if remove: new_list = [ x for x in get_server_config(ctx.guild.id, 'inactivity_channels', list) if x != channel.id ] write_server_config(ctx.guild.id, 'inactivity_channels', new_list) await ctx.reply( get_language_str(ctx.guild.id, 39).format(channel.id)) return else: new_list = get_server_config(ctx.guild.id, 'inactivity_channels', list) new_list.append(channel.id) write_server_config(ctx.guild.id, 'inactivity_channels', new_list) await ctx.reply( get_language_str(ctx.guild.id, 40).format(channel.id)) return