Esempio n. 1
0
 async def showjoinleaveconfig(self, ctx):
     """Shows the on user join and leave config"""
     await ctx.channel.trigger_typing()
     join_message = read_data_entry(ctx.guild.id, "join-message")
     if join_message is not None:
         join_message = join_message.replace("%user%", "@{}".format(ctx.author.name)).replace("%server%", ctx.guild.name)
     leave_message = read_data_entry(ctx.guild.id, "leave-message")
     if leave_message is not None:
         leave_message = leave_message.replace("%user%", "@{}".format(ctx.author.name)).replace("%server%", ctx.guild.name)
     join_leave_channel_id = read_data_entry(ctx.guild.id, "join-leave-channel")
     if join_leave_channel_id is not None:
         join_leave_channel = discord.utils.get(ctx.guild.channels, id=join_leave_channel_id).mention
         if join_leave_channel is None:
             update_data_entry(ctx.guild.id, "join-leave-channel", None)
     else:
         join_leave_channel = None
     join_role_id = read_data_entry(ctx.guild.id, "join-role")
     if join_role_id is not None:
         join_role = discord.utils.get(ctx.guild.roles, id=join_role_id).name
         if join_role is None:
             update_data_entry(ctx.guild.id, "join-role", None)
     else:
         join_role = None
     fields = {Language.get("configuration.join_message", ctx):join_message, Language.get("configuration.leave_message", ctx):leave_message, Language.get("configuration.channel", ctx):join_leave_channel, Language.get("configuration.join_role", ctx):join_role}
     embed = make_list_embed(fields)
     embed.title = Language.get("configuration.showjoinleaveconfig_title", ctx)
     embed.color = 0xFF0000
     await ctx.send(embed=embed)
Esempio n. 2
0
 async def createrole(self, ctx, *, name:str):
     """Creates a role with the specified name"""
     try:
         await ctx.guild.create_role(name=name, reason=Language.get("createrole_reason", ctx).format(ctx.author), permissions=ctx.guild.default_role.permissions)
         await ctx.send(Language.get("createrole_success", ctx).format(name))
     except discord.errors.Forbidden:
         await ctx.send(Language.get("moderation.no_manage_role_perms", ctx))
Esempio n. 3
0
 async def config(self, ctx, type:str, *, value:str):
     """Modifies the server's local config"""
     await ctx.channel.trigger_typing()
     if type == "mod-role" or type == "mute-role":
         update_data_entry(ctx.guild.id, type, value)
         await ctx.send(Language.get("configuration.set_success", ctx).format(type, value))
     else:
         await ctx.send(Language.get("configuration.invalid_set_type", ctx).format(type))
Esempio n. 4
0
 async def emoteinfo(self, ctx, *, emote:discord.Emoji):
     """Gets information on a custom emote (Only works for servers the bot is on)"""
     fields = {Language.get("information.name", ctx):emote.name, Language.get("information.id", ctx):emote.id, Language.get("information.server_origin", ctx):emote.guild.name, Language.get("information.created_on", ctx):format_time(emote.created_at), Language.get("information.colons_required", ctx):emote.require_colons, Language.get("information.managed_by_twitch", ctx):emote.managed}
     embed = make_list_embed(fields)
     embed.title = ":{}:".format(emote.name)
     embed.color = 0xFF0000
     embed.set_thumbnail(url=emote.url)
     await ctx.send(embed=embed)
Esempio n. 5
0
 async def rate(self, ctx, user:discord.User=None):
     """Have the bot rate yourself or another user (rigged af)"""
     if user is None or user.id == ctx.author.id:
         await ctx.send(Language.get("fun.rate_author", ctx))
     elif user == self.bot.user:
         await ctx.send(Language.get("fun.rate_self", ctx))
     else:
         await ctx.send(Language.get("fun.rate_user", ctx).format(user.name, random.randint(0, 10)))
Esempio n. 6
0
async def stream(ctx, *, name:str):
    """Sets the streaming status with the specified name"""
    if lock_status:
        if not ctx.author.id == config.owner_id and not ctx.author.id in config.dev_ids:
            await ctx.send(Language.get("bot.status_locked", ctx))
            return
    await bot.change_presence(activity=discord.Activity(name=name, type=discord.ActivityType.streaming, url="https://www.twitch.tv/ZeroEpoch1969"))
    await ctx.send(Language.get("bot.now_streaming", ctx).format(name))
    await channel_logger.log_to_channel(":information_source: `{}`/`{}` has changed the streaming status to `{}`".format(ctx.author.id, ctx.author, name))
Esempio n. 7
0
 async def showconfig(self, ctx):
     """Shows the server's configuration"""
     await ctx.channel.trigger_typing()
     mod_role_name = read_data_entry(ctx.guild.id, "mod-role")
     mute_role_name = read_data_entry(ctx.guild.id, "mute-role")
     fields = {Language.get("configuration.mod_role", ctx):mod_role_name, Language.get("configuration.mute_role", ctx):mute_role_name}
     embed = make_list_embed(fields)
     embed.title = Language.get("configuration.server_configuration", ctx)
     embed.color = 0xFF0000
     await ctx.send(embed=embed)
Esempio n. 8
0
 async def joinleave(self, ctx, type:str, *, value:str):
     """Configures on user join and leave settings"""
     await ctx.channel.trigger_typing()
     if type == "join-message":
         update_data_entry(ctx.guild.id, type, value)
         await ctx.send(Language.get("configuration.join_message_set_success", ctx).format(value.replace("%user%", "@{}".format(ctx.author.name)).replace("%server%", ctx.guild.name)))
     elif type == "leave-message":
         update_data_entry(ctx.guild.id, type, value)
         await ctx.send(Language.get("configuration.leave_message_set_success", ctx).format(value.replace("%user%", "@{}".format(ctx.author.name)).replace("%server%", ctx.guild.name)))
     elif type == "channel":
         if value == "remove":
             update_data_entry(ctx.guild.id, "join-leave-channel", None)
             await ctx.send(Language.get("configuration.join-leave_disabled", ctx))
             return
         channel = discord.utils.get(ctx.guild.channels, name=value)
         if channel is None:
             await ctx.send(Language.get("configuration.channel_not_found", ctx).format(value))
             return
         update_data_entry(ctx.guild.id, "join-leave-channel", channel.id)
         await ctx.send(Language.get("configuration.join-leave_channel_set_success", ctx).format(channel.mention))
     elif type == "join-role":
         if value == "remove":
             update_data_entry(ctx.guild.id, type, None)
             await ctx.send(Language.get("configuration.join-leave_role_disabled", ctx))
             return
         role = discord.utils.get(ctx.guild.roles, name=value)
         if role is None:
             await ctx.send(Language.get("configuration.role_not_found", ctx).format(value))
             return
         update_data_entry(ctx.guild.id, type, role.id)
         await ctx.send(Language.get("configuration.join-role_set_success", ctx).format(role.name))
     else:
         await ctx.send(Language.get("configuration.join_settings_invalid_type", ctx).format(type))
Esempio n. 9
0
 async def pin(self, ctx, id:int):
     """Pins the message with the specified ID to the channel"""
     try:
         message = await ctx.channel.fetch_message(id)
     except discord.errors.NotFound:
         await ctx.send(Language.get("bot.no_message_found", ctx).format(id))
         return
     try:
         await message.pin()
     except discord.errors.Forbidden:
         await ctx.send(Language.get("moderation.no_manage_messages_perms", ctx))
Esempio n. 10
0
 async def kick(self, ctx, user:discord.Member):
     """Kicks the specified user from the server"""
     try:
         await ctx.guild.kick(user)
     except discord.errors.Forbidden:
         if user.top_role.position == ctx.me.top_role.position:
             await ctx.send(Language.get("moderation.no_kick_highest_role", ctx))
         elif user.top_role.position > ctx.me.top_role.position:
             await ctx.send(Language.get("moderation.no_kick_higher_role", ctx))
         else:
             await ctx.send(Language.get("moderation.no_kick_perms", ctx))
     await ctx.send(Language.get("moderation.kick_success", ctx).format(user))
Esempio n. 11
0
 async def unpin(self, ctx, id:int):
     """Unpins the message with the specified ID from the channel"""
     pinned_messages = await ctx.channel.pins()
     message = discord.utils.get(pinned_messages, id=id)
     if message is None:
         await ctx.send(Language.get("moderation.no_pinned_message_found", ctx).format(id))
         return
     try:
         await message.unpin()
         await ctx.send(Language.get("moderation.unpin_success", ctx))
     except discord.errors.Forbidden:
         await ctx.send(Language.get("moderation.no_manage_messages_perms", ctx))
Esempio n. 12
0
 async def removereactions(self, ctx, id:int):
     """Clear reactions from a message"""
     try:
         message = await ctx.channel.fetch_message(id)
     except discord.errors.NotFound:
         await ctx.send(Language.get("bot.no_message_found", ctx).format(id))
         return
     try:
         await message.clear_reactions()
         await ctx.send(Language.get("moderation.removereactions_success", ctx))
     except discord.errors.Forbidden:
         await ctx.send(Language.get("moderation.no_manage_messages_perms", ctx))
Esempio n. 13
0
 async def isitdown(self, ctx, *, url:str):
     """Checks to see if a website is online or not"""
     await ctx.channel.trigger_typing()
     url = url.strip("<>")
     if not url.startswith("http://") and not url.startswith("https://"):
         url = "http://{}".format(url)
     try:
         starttime = time.time()
         requests.get(url, timeout=3)
         ping = Language.get("information.ping_time", ctx) % (time.time() - starttime)
         await ctx.send(Language.get("information.online_ping", ctx).format(url, ping))
     except:
         await ctx.send(Language.get("information.offline_ping", ctx).format(url))
Esempio n. 14
0
 async def serverinfo(self, ctx):
     """Gets information on the current server"""
     guild = ctx.guild
     human_count = len([member for member in guild.members if not member.bot])
     bot_count = len(([member for member in guild.members if member.bot]))
     timeout_times = {60:Language.get("information.timeout_times.60", ctx), 300:Language.get("information.timeout_times.300", ctx), 900:Language.get("information.timeout_times.900", ctx), 1800:Language.get("information.timeout_times.1800", ctx), 3600:Language.get("information.timeout_times.3600", ctx)}
     fields = {Language.get("information.id", ctx):guild.id, Language.get("information.created_on", ctx):format_time(guild.created_at), Language.get("information.region", ctx):guild.region, Language.get("information.member_count_title", ctx).format(len(guild.members)):Language.get("information.member_count", ctx).format(human_count, bot_count), Language.get("information.channel_count_title", ctx).format(len(guild.channels)):Language.get("information.channel_count", ctx).format(len(guild.text_channels), len(guild.voice_channels)), Language.get("information.role_count", ctx):len(guild.roles), Language.get("information.owner", ctx):guild.owner, Language.get("information.owner_id", ctx):guild.owner_id, Language.get("information.afk_channel", ctx):guild.afk_channel, Language.get("information.afk_timeout", ctx):timeout_times[guild.afk_timeout], Language.get("information.verification_level", ctx):str(ctx.guild.verification_level).capitalize().replace("High", tableflip).replace("Extreme", doubleflip), Language.get("information.2fa_enabled", ctx):convert_to_bool(guild.mfa_level)}
     embed = make_list_embed(fields)
     embed.title = guild.name
     embed.color = 0xFF0000
     if guild.icon_url:
         embed.set_thumbnail(url=guild.icon_url)
     await ctx.send(embed=embed)
Esempio n. 15
0
 async def osu(self, ctx, *, username:str):
     """Gets an osu! profile stats with the specified name"""
     if not config.enableOsu:
         await ctx.send(Language.get("information.osu_command_disabled", ctx))
         return
     try:
         import osuapi
     except ImportError:
         log.critical("The osu api is enabled, but the osuapi module was not found! Please run \"pip install osuapi\"")
         await ctx.send(Language.get("osu_import_fail", ctx))
         return
     await ctx.channel.trigger_typing()
     api = osuapi.OsuApi(config._osuKey, connector=osuapi.AHConnector())
     try:
         user = await api.get_user(username)
     except osuapi.HTTPError as e:
         if e.code == 401:
             log.critical("An invalid osu! api key was set, please check the config for instructions on how to get a proper api key!")
             await ctx.send(Language.get("information.osu_invalid_key", ctx))
             return
         else:
             log.critical("An unknown error occured while trying to get an osu! profile.")
             await ctx.send(Language.get("information.osu_unknown_error", ctx))
             return
     try:
         user = user[0]
     except IndexError:
         await ctx.send(Language.get("information.no_osu_profile_found", ctx).format(username))
         return
     fields = {Language.get("information.id", ctx):user.user_id, Language.get("information.country", ctx):user.country, Language.get("information.level", ctx):int(user.level), Language.get("information.hits", ctx):user.total_hits, Language.get("information.score", ctx):user.total_score, Language.get("information.accuracy", ctx):"{0:.2f}%".format(user.accuracy), Language.get("information.play_count", ctx):user.playcount, Language.get("information.ranked_score", ctx):user.ranked_score, Language.get("information.a_rank", ctx):user.count_rank_a, Language.get("information.s_rank", ctx):user.count_rank_s, Language.get("information.ss_rank", ctx):user.count_rank_ss}
     embed = make_list_embed(fields)
     embed.title = Language.get("information.osu_stats_title", ctx).format(user.username)
     embed.color = 0xFF00FF
     embed.set_thumbnail(url="http://s.ppy.sh/a/{}".format(user.user_id))
     await ctx.send(embed=embed)
Esempio n. 16
0
 async def getuserbyid(self, ctx, id:int):
     """Gets a user by id"""
     user = discord.utils.get(list(self.bot.get_all_members()), id=id)
     if not user:
         await ctx.send(Language.get("information.no_mutual_servers", ctx).format(id))
         return
     if user.game:
         game = user.game.name
     fields = {Language.get("information.name", ctx):user.name, Language.get("information.discriminator", ctx):user.discriminator, Language.get("information.id", ctx):user.id, Language.get("information.statud", ctx):str(user.status).replace("dnd", "do not disturb"), Language.get("information.game", ctx):game, Language.get("information.boot", ctx):user.bot}
     embed = make_list_embed(fields)
     embed.title = str(user)
     embed.color = 0xFF0000
     embed.set_thumbnail(url=get_avatar(user))
     await ctx.send(embed=embed)
Esempio n. 17
0
 async def massban(self, ctx, *, ids:str):
     """Mass bans users by ids (separate ids with spaces)"""
     await ctx.channel.trigger_typing()
     ids = ids.split(" ")
     failed_ids = []
     success = 0
     for id in ids:
         try:
             await self.bot.http.ban(int(id), ctx.guild.id, delete_message_days=0)
             success += 1
         except:
             failed_ids.append("`{}`".format(id))
     if len(failed_ids) != 0:
         await ctx.send(Language.get("moderation.massban_failed_ids", ctx).format(", ".join(ids)))
     await ctx.send(Language.get("moderation.massban_success", ctx).format(success, len(ids)))
Esempio n. 18
0
 async def prune(self, ctx, amount:int):
     """Prunes the specified amount of messages (you can also prune messages from a specific user too)"""
     try:
         await ctx.message.delete()
     except discord.errors.Forbidden:
         await ctx.send(Language.get("moderation.no_manage_messages_perms", ctx))
         return
     deleted = await ctx.channel.purge(limit=amount)
     deleted_message = await ctx.send(Language.get("moderation.pruned", ctx).format(ctx.author.mention, len(deleted)))
     await asyncio.sleep(10)
     # The try and except pass is so in the event a user prunes again or deletes the prune notification before the bot automatically does it, it will not raise an error
     try:
         await deleted_message.delete()
     except:
         pass
Esempio n. 19
0
 async def unban(self, ctx, *, username:str):
     """Unbans the user with the specifed name from the server"""
     try:
         banlist = await ctx.guild.bans()
     except discord.errors.Forbidden:
         await ctx.send(Language.get("moderation.no_ban_perms", ctx))
         return
     user = None
     for ban in banlist:
         if ban.user.name == username:
             user = ban.user
     if user is None:
         await ctx.send(Language.get("moderation.user_not_banned", ctx).format(username))
         return
     await ctx.guild.unban(user)
     await ctx.send(Language.get("moderation.unban_success", ctx).format(user))
Esempio n. 20
0
async def ping(ctx):
    """Pings the bot"""
    pingms = await ctx.send(Language.get("bot.pinging", ctx))
    start = time.time()
    async with aiosession.get("https://discordapp.com"):
        duration = time.time() - start
    duration = round(duration * 1000)
    await pingms.edit(content="{0} // **{1}ms**".format(pingms.content, duration))
Esempio n. 21
0
 async def getemotes(self, ctx):
     """Gets a list of the server's emotes"""
     emotes = ctx.guild.emojis
     if len(emotes) == 0:
         await ctx.send(Language.get("information.no_server_emotes", ctx))
         return
     emotes = ["`:{}:` = {}".format(emote.name, emote) for emote in emotes]
     await ctx.send("\n".join(emotes))
Esempio n. 22
0
async def uptime(ctx):
    """Displays how long the bot has been online for"""
    second = time.time() - start_time
    minute, second = divmod(second, 60)
    hour, minute = divmod(minute, 60)
    day, hour = divmod(hour, 24)
    week, day = divmod(day, 7)
    await ctx.send(Language.get("bot.uptime", ctx) % (week, day, hour, minute, second))
Esempio n. 23
0
async def stats(ctx):
    """Gets the bot's stats"""
    voice_clients = []
    for guild in bot.guilds:
        if guild.me.voice:
            voice_clients.append(guild.me.voice.channel)
    fields = {Language.get("bot.stats.users", ctx):len(list(bot.get_all_members())), Language.get("bot.stats.servers", ctx):len(bot.guilds), Language.get("bot.stats.channels", ctx):len(list(
        bot.get_all_channels())), Language.get("bot.stats.voice_clients", ctx):len(voice_clients), Language.get("bot.stats.discordpy_version", ctx):discord.__version__, Language.get("bot.stats.bot_version", ctx):
              BUILD_VERSION, Language.get("bot.stats.built_by", ctx):BUILD_AUTHORS, Language.get("bot.stats.translators", ctx):", ".join(TRANSLATORS.keys())}
    embed = make_list_embed(fields)
    embed.title = str(bot.user)
    embed.color = 0xFF0000
    embed.set_thumbnail(url=bot.user.avatar_url)
    bot_owner = discord.utils.get(list(bot.get_all_members()), id=config.owner_id)
    if bot_owner is not None:
        embed.set_footer(text=bot_owner, icon_url=get_avatar(bot_owner))
    await ctx.send(embed=embed)
Esempio n. 24
0
async def ping(ctx):
    """Pings the bot"""
    pingms = await ctx.send(Language.get("bot.pinging", ctx))
    start = time.time()
    async with aiosession.get("https://discord.com"):
        duration = time.time() - start
    duration = round(duration * 1000)
    await pingms.edit(
        content="{0} // **{1}ms**".format(pingms.content, duration))
Esempio n. 25
0
 async def prune(self, ctx, amount: int):
     """Prunes the specified amount of messages (you can also prune messages from a specific user too)"""
     try:
         await ctx.message.delete()
     except discord.errors.Forbidden:
         await ctx.send(
             Language.get("moderation.no_manage_messages_perms", ctx))
         return
     deleted = await ctx.channel.purge(limit=amount)
     deleted_message = await ctx.send(
         Language.get("moderation.pruned",
                      ctx).format(ctx.author.mention, len(deleted)))
     await asyncio.sleep(10)
     # The try and except pass is so in the event a user prunes again or deletes the prune notification before the bot automatically does it, it will not raise an error
     try:
         await deleted_message.delete()
     except:
         pass
Esempio n. 26
0
async def uptime(ctx):
    """Displays how long the bot has been online for"""
    second = time.time() - start_time
    minute, second = divmod(second, 60)
    hour, minute = divmod(minute, 60)
    day, hour = divmod(hour, 24)
    week, day = divmod(day, 7)
    await ctx.send(
        Language.get("bot.uptime", ctx) % (week, day, hour, minute, second))
Esempio n. 27
0
 async def disconnect(self, ctx):
     """Disconnects the bot from the voice channel"""
     await ctx.voice_client.disconnect()
     try:
         self.clear_data(ctx.guild.id)
         del self.queues[ctx.guild.id]
     except:
         pass
     await ctx.send(Language.get("music.disconnected", ctx))
Esempio n. 28
0
 def __init__(self, master=None):
     tk.Toplevel.__init__(self, master)
     self._master = master
     self.language = Language("EquantMainFrame")
     self.setPos()
     #图标
     self.iconbitmap(bitmap=r"./icon/epolestar ix2.ico")
     # 点击窗口右侧关闭按钮事件
     self.protocol("WM_DELETE_WINDOW", self.closeEvent)
Esempio n. 29
0
 async def audio_change_task(self):
     while True:
         self.play_next_song.clear()
         self.current = await self.songs.get()
         self.song_list.remove(str(self.current))
         self.skip_votes.clear()
         await self.text_channel.send(Language.get("music.now_playing", self.text_channel).format(self.current.title_with_requester()))
         self.voice_client.play(self.current.entry, after=lambda e: self.play_next_song.set())
         await self.play_next_song.wait()
Esempio n. 30
0
 async def banid(self, ctx, id:int, *, reason:str=None):
     """Bans the user with the specified id from the server (Useful if the user isn't on the server yet)"""
     if reason is None:
         reason = Language.get("moderation.no_reason", ctx)
     reason += Language.get("moderation.banned_by", ctx).format(ctx.author)
     try:
         await self.bot.http.ban(id, ctx.guild.id, delete_message_days=0, reason=reason)
     except discord.errors.HTTPException or discord.errors.NotFound:
         await ctx.send(Language.get("moderation.invalid_user_id", ctx).format(id))
         return
     except discord.errors.Forbidden:
         await ctx.send(Language.get("moderation.no_ban_perms", ctx))
         return
     banlist = await ctx.guild.bans()
     for ban in banlist:
         if ban.user.id == id:
             user = ban.user
     await ctx.send(Language.get("moderation.ban_success", ctx).format(user))
Esempio n. 31
0
 async def emoteurl(self, ctx, *, emote:str):
     """Gets the url for a CUSTOM emote (meaning no unicode emotes)"""
     emote_id = extract_emote_id(emote)
     if emote_id is None:
         await ctx.send(Language.get("information.non-custom_emote", ctx))
         return
     extension = "png"
     if emote.startswith("<a"):
         extension = "gif"
     await ctx.send("https://discordapp.com/api/emojis/{}.{}".format(emote_id, extension))
Esempio n. 32
0
async def notifydev(ctx, *, message:str):
	"""Sends a message to the developers"""
	if isinstance(ctx.channel, discord.DMChannel):
		guild = "`No server! Sent via Private Message!`"
	else:
		guild = "`{}` / `{}`".format(ctx.guild.id, ctx.guild.name)
	msg = make_message_embed(ctx.author, 0xFF0000, message, formatUser=True)
	owner = await bot.fetch_user(466778567905116170)
	await owner.send("You have received a new message! The user's ID is `{}` Server: {}".format(ctx.author.id, guild), embed=msg)
	await ctx.send(Language.get("bot.dev_notify", ctx).format(message))
Esempio n. 33
0
 async def unban(self, ctx, *, username: str):
     """Unbans the user with the specifed name from the server"""
     try:
         banlist = await ctx.guild.bans()
     except discord.errors.Forbidden:
         await ctx.send(Language.get("moderation.no_ban_perms", ctx))
         return
     user = None
     for ban in banlist:
         if ban.user.name == username:
             user = ban.user
     if user is None:
         await ctx.send(
             Language.get("moderation.user_not_banned",
                          ctx).format(username))
         return
     await ctx.guild.unban(user)
     await ctx.send(
         Language.get("moderation.unban_success", ctx).format(user))
Esempio n. 34
0
 def clean( self ):
     cleaned_data = super().clean()
     problemslug = cleaned_data.get( 'problemslug' )
     code = cleaned_data.get( 'code' )
     language = Language.get_language( cleaned_data.get( 'language' ) )
     s = get_object_or_None( Problem , slug = problemslug )
     if problemslug and s is None:
         self.add_error( 'problemslug' , 'Problem not exists.' )
     if language is None:
         self.add_error( 'language' , 'Unknown language' )
Esempio n. 35
0
	async def massban(self, ctx, *, ids:str):
		"""Mass bans users by ids (separate ids with spaces)"""
		await ctx.channel.trigger_typing()
		ids = ids.split(" ")
		guild = ctx.guild
		failed_ids = []
		success = 0
		for id in ids:
			try:
				await self.bot.http.ban(int(id), ctx.guild.id, delete_message_days=0)
				success += 1
			except:
				failed_ids.append("`{}`".format(id))
		if len(failed_ids) != 0:
			await ctx.send(Language.get("moderation.massban_failed_ids", ctx).format(", ".join(ids)))
		await ctx.send(Language.get("moderation.massban_success", ctx).format(success, len(ids)))
		for channel in guild.channels:
			if channel.name == "logs":
				await channel.send(Language.get("moderation.massban_success", ctx).format(success, len(ids)))
Esempio n. 36
0
 async def yandere(self, ctx, *, tags:str):
     """Searches yande.re for the specified tagged images"""
     await ctx.channel.trigger_typing()
     try:
         data = requests.get("https://yande.re/post/index.json?limit={}&tags={}".format(limit, tags), headers=header).json()
     except json.JSONDecodeError:
         await ctx.send(Language.get("nsfw.no_results_found", ctx).format(tags))
         return
     count = len(data)
     if count == 0:
         await ctx.send(Language.get("nsfw.no_results_found", ctx).format(tags))
         return
     image_count = 4
     if count < 4:
         image_count = count
     images = []
     for i in range(image_count):
         images.append(data[random.randint(0, count)]["file_url"])
     await ctx.send(Language.get("nsfw.results", ctx).format(image_count, count, tags, "\n".join(images)))
Esempio n. 37
0
 async def yandere(self, ctx, *, tags:str):
     """Searches yande.re for the specified tagged images"""
     await ctx.channel.trigger_typing()
     try:
         data = json.loads(requests.get("https://yande.re/post/index.json?limit={}&tags={}".format(limit, tags)).text)
     except json.JSONDecodeError:
         await ctx.send(Language.get("nsfw.no_results_found", ctx).format(tags))
         return
     count = len(data)
     if count == 0:
         await ctx.send(Language.get("nsfw.no_results_found", ctx).format(tags))
         return
     image_count = 4
     if count < 4:
         image_count = count
     images = []
     for i in range(image_count):
         images.append(data[random.randint(0, count)]["file_url"])
     await ctx.send(Language.get("nsfw.results", ctx).format(image_count, count, tags, "\n".join(images)))
Esempio n. 38
0
 async def manga(self, ctx, *, name:str):
     """Searches MyAnimeList for the specified manga"""
     await ctx.channel.trigger_typing()
     r = requests.get("https://myanimelist.net/api/manga/search.xml?q={}".format(name), auth=requests.auth.HTTPBasicAuth(config._malUsername, config._malPassword))
     if r.status_code == 401:
         log.critical("The MyAnimeList credinals are incorrect, please check your MyAnimeList login information in the config.")
         await ctx.send(Language.get("myanimelist.incorrect_creds", ctx))
         return
     try:
         xmldoc = minidom.parseString(r.text)
     except XmlParserErrors.ExpatError:
         await ctx.send(Language.get("myanimelist.no_manga_found", ctx).format(name))
         return
     # pls no flame
     manga = xmldoc.getElementsByTagName("entry")[0]
     id = manga.getElementsByTagName("id")[0].firstChild.nodeValue
     title = manga.getElementsByTagName("title")[0].firstChild.nodeValue
     try:
         english = manga.getElementsByTagName("english")[0].firstChild.nodeValue
     except:
         english = title
     chapters = manga.getElementsByTagName("chapters")[0].firstChild.nodeValue
     volumes = manga.getElementsByTagName("volumes")[0].firstChild.nodeValue
     score = manga.getElementsByTagName("score")[0].firstChild.nodeValue
     type = manga.getElementsByTagName("type")[0].firstChild.nodeValue
     status = manga.getElementsByTagName("status")[0].firstChild.nodeValue
     start_date = manga.getElementsByTagName("start_date")[0].firstChild.nodeValue
     end_date = manga.getElementsByTagName("end_date")[0].firstChild.nodeValue
     image = manga.getElementsByTagName("image")[0].firstChild.nodeValue
     synopsis = saxutils.unescape(manga.getElementsByTagName("synopsis")[0].firstChild.nodeValue)
     synopsis = remove_html(synopsis)
     if len(synopsis) > 300:
         synopsis = synopsis[:300] + "..."
     url = "https://myanimelist.net/manga/{}".format(id)
     fields = {Language.get("myanimelist.english_title", ctx):english, Language.get("myanimelist.chapaters", ctx):chapters, Language.get("myanimelist.volumes", ctx):volumes, Language.get("myanimelist.mal_history", ctx):score, Language.get("myanimelist.type", ctx):type, Language.get("myanimelist.status", ctx):status, Language.get("myanimelist.start_date", ctx):start_date, Language.get("myanimelist.end_date", ctx):end_date}
     embed = make_list_embed(fields)
     embed.title = title
     embed.description = synopsis
     embed.url = url
     embed.color = 0xFF0000
     embed.set_thumbnail(url=image)
     await ctx.send(embed=embed)
Esempio n. 39
0
 async def manga(self, ctx, *, name:str):
     """Searches MyAnimeList for the specified manga"""
     await ctx.channel.trigger_typing()
     r = requests.get("https://myanimelist.net/api/manga/search.xml?q={}".format(name), auth=requests.auth.HTTPBasicAuth(config._malUsername, config._malPassword))
     if r.status_code == 401:
         log.critical("The MyAnimeList credinals are incorrect, please check your MyAnimeList login information in the config.")
         await ctx.send(Language.get("myanimelist.incorrect_creds", ctx))
         return
     try:
         xmldoc = minidom.parseString(r.text)
     except XmlParserErrors.ExpatError:
         await ctx.send(Language.get("myanimelist.no_manga_found", ctx).format(name))
         return
     # pls no flame
     manga = xmldoc.getElementsByTagName("entry")[0]
     id = manga.getElementsByTagName("id")[0].firstChild.nodeValue
     title = manga.getElementsByTagName("title")[0].firstChild.nodeValue
     try:
         english = manga.getElementsByTagName("english")[0].firstChild.nodeValue
     except:
         english = title
     chapters = manga.getElementsByTagName("chapters")[0].firstChild.nodeValue
     volumes = manga.getElementsByTagName("volumes")[0].firstChild.nodeValue
     score = manga.getElementsByTagName("score")[0].firstChild.nodeValue
     type = manga.getElementsByTagName("type")[0].firstChild.nodeValue
     status = manga.getElementsByTagName("status")[0].firstChild.nodeValue
     start_date = manga.getElementsByTagName("start_date")[0].firstChild.nodeValue
     end_date = manga.getElementsByTagName("end_date")[0].firstChild.nodeValue
     image = manga.getElementsByTagName("image")[0].firstChild.nodeValue
     synopsis = saxutils.unescape(manga.getElementsByTagName("synopsis")[0].firstChild.nodeValue)
     synopsis = remove_html(synopsis)
     if len(synopsis) > 300:
         synopsis = synopsis[:300] + "..."
     url = "https://myanimelist.net/manga/{}".format(id)
     fields = {Language.get("myanimelist.english_title", ctx):english, Language.get("myanimelist.chapaters", ctx):chapters, Language.get("myanimelist.volumes", ctx):volumes, Language.get("myanimelist.mal_history", ctx):score, Language.get("myanimelist.type", ctx):type, Language.get("myanimelist.status", ctx):status, Language.get("myanimelist.start_date", ctx):start_date, Language.get("myanimelist.end_date", ctx):end_date}
     embed = make_list_embed(fields)
     embed.title = title
     embed.description = synopsis
     embed.url = url
     embed.color = 0xFF0000
     embed.set_thumbnail(url=image)
     await ctx.send(embed=embed)
Esempio n. 40
0
 async def volume(self, ctx, amount:float=None):
     """Sets the volume, for developers only because you set the volume via the bot's volume slider. This command is for debugging."""
     queue = self.get_queue(ctx)
     if not ctx.author.id == config.owner_id and ctx.author.id not in config.dev_ids:
         await ctx.send(Language.get("music.volume_notice", ctx))
         return
     if not amount:
         await ctx.send("The current volume is `{:.0%}`".format(queue.voice_client.source.volume))
         return
     queue.voice_client.source.volume = amount / 100 #owo
     await ctx.send("Set the internal volume to `{:.0%}`".format(queue.voice_client.source.volume))
Esempio n. 41
0
    async def rule34(self, ctx, *, tags:str):
        await ctx.channel.trigger_typing()
        try:
            data = json.loads(requests.get("http://rule34.xxx/index.php?page=dapi&s=post&q=index&json=1&limit={}&tags={}".format(limit, tags)).text)
        except json.JSONDecodeError:
            await ctx.send(Language.get("nsfw.no_results_found", ctx).format(tags))
            return

        count = len(data)
        if count == 0:
            await ctx.send(Language.get("nsfw.no_results_found", ctx).format(tags))
            return
        image_count = 4
        if count < 4:
            image_count = count
        images = []
        for i in range(image_count):
            image = data[random.randint(0, count)]
            images.append("http://img.rule34.xxx/images/{}/{}".format(image["directory"], image["image"]))
        await ctx.send(Language.get("nsfw.results", ctx).format(image_count, count, tags, "\n".join(images)))
Esempio n. 42
0
 async def color(self, ctx, *, hexcode:str):
     """Displays the given hex color"""
     await ctx.channel.trigger_typing()
     if not hexcode.startswith("#"):
         hexcode = "#{}".format(hexcode)
     try:
         Image.new("RGBA", (50, 50), hexcode).save("data/color.png")
     except ValueError:
         await ctx.send(Language.get("bot.invalid_color", ctx).format(hexcode))
         return
     await ctx.send(file=discord.File("data/color.png", "{}.png".format(hexcode.strip("#"))))
Esempio n. 43
0
    async def rule34(self, ctx, *, tags:str):
        await ctx.channel.trigger_typing()
        try:
            data = requests.get("http://rule34.xxx/index.php?page=dapi&s=post&q=index&json=1&limit={}&tags={}".format(limit, tags), headers=header).json()
        except json.JSONDecodeError:
            await ctx.send(Language.get("nsfw.no_results_found", ctx).format(tags))
            return

        count = len(data)
        if count == 0:
            await ctx.send(Language.get("nsfw.no_results_found", ctx).format(tags))
            return
        image_count = 4
        if count < 4:
            image_count = count
        images = []
        for i in range(image_count):
            image = data[random.randint(0, count)]
            images.append("http://img.rule34.xxx/images/{}/{}".format(image["directory"], image["image"]))
        await ctx.send(Language.get("nsfw.results", ctx).format(image_count, count, tags, "\n".join(images)))
Esempio n. 44
0
 async def discrim(self, ctx, *, discriminator:str):
     """Gets a username#discriminator list of all users that the bot can see with the specified discriminator"""
     members = []
     for member in list(self.bot.get_all_members()):
         if member.discriminator == discriminator and str(member) not in members:
             members.append(str(member))
     if len(members) == 0:
         members = Language.get("information.no_discrims_found", ctx).format(discriminator)
     else:
         members = "```{}```".format(", ".join(members))
     await ctx.send(members)
Esempio n. 45
0
 async def showjoinleaveconfig(self, ctx):
     """Shows the on user join and leave config"""
     await ctx.channel.trigger_typing()
     join_message = read_data_entry(ctx.guild.id, "join-message")
     if join_message is not None:
         join_message = join_message.replace("%user%", "@{}".format(
             ctx.author.name)).replace("%server%", ctx.guild.name)
     leave_message = read_data_entry(ctx.guild.id, "leave-message")
     if leave_message is not None:
         leave_message = leave_message.replace(
             "%user%",
             "@{}".format(ctx.author.name)).replace("%server%",
                                                    ctx.guild.name)
     join_leave_channel_id = read_data_entry(ctx.guild.id,
                                             "join-leave-channel")
     if join_leave_channel_id is not None:
         join_leave_channel = discord.utils.get(
             ctx.guild.channels, id=join_leave_channel_id).mention
         if join_leave_channel is None:
             update_data_entry(ctx.guild.id, "join-leave-channel", None)
     else:
         join_leave_channel = None
     join_role_id = read_data_entry(ctx.guild.id, "join-role")
     if join_role_id is not None:
         join_role = discord.utils.get(ctx.guild.roles,
                                       id=join_role_id).name
         if join_role is None:
             update_data_entry(ctx.guild.id, "join-role", None)
     else:
         join_role = None
     fields = {
         Language.get("configuration.join_message", ctx): join_message,
         Language.get("configuration.leave_message", ctx): leave_message,
         Language.get("configuration.channel", ctx): join_leave_channel,
         Language.get("configuration.join_role", ctx): join_role
     }
     embed = make_list_embed(fields)
     embed.title = Language.get("configuration.showjoinleaveconfig_title",
                                ctx)
     embed.color = 0xFF0000
     await ctx.send(embed=embed)
Esempio n. 46
0
 async def react(self, ctx, id:int, emote:str):
     """Reacts to a message with the specifed message id and the specified emote"""
     try:
          message = await ctx.channel.fetch_message(id)
     except discord.errors.NotFound:
         await ctx.send(Language.get("bot.no_message_found", ctx).format(id))
         return
     emote_id = extract_emote_id(emote)
     if emote_id is not None:
         server_emote = discord.utils.get(list(self.bot.get_all_emojis), id=emote_id)
         if server_emote is not None:
             emote = server_emote
         else:
             await ctx.send(Language.get("fun.no_emote_found", ctx))
             return
     try:
         await ctx.add_reaction(message, emote)
     except discord.errors.Forbidden:
         await ctx.send(Language.get("fun.no_reaction_perms", ctx))
     except discord.errors.HTTPException:
         await ctx.send(Language.get("fun.invalid_emote", ctx))
Esempio n. 47
0
 async def portscan(self, ctx, host:str, ports:str):
     """Uses nmap to scan the specified ports from the specified host"""
     await ctx.channel.trigger_typing()
     forbidden_hosts = ["localhost", "0.0.0.0", "127.0.0.1"]
     if host in forbidden_hosts:
         await ctx.send(Language.get("information.forbidden_host", ctx).format(host))
         return
     scanner = nmap.PortScanner()
     try:
         host = socket.gethostbyname(host)
     except socket.gaierror:
         await ctx.send("`{}` is not a valid address".format(host))
         return
     ports = scanner.scan(host, ports)["scan"][host]["tcp"]
     results = []
     for port, data in ports.items():
         service = data["name"]
         if service == "":
             service = Language.get("information.unknown", ctx)
         results.append(Language.get("information.port_status", ctx).format(port, service, data["state"]))
     await ctx.send(xl.format("\n".join(results)))
Esempio n. 48
0
 async def unmute(self, ctx, user: discord.Member):
     """Unmutes the specified user"""
     mute_role_name = read_data_entry(ctx.guild.id, "mute-role")
     mute_role = discord.utils.get(ctx.guild.roles, name=mute_role_name)
     if mute_role is None:
         await ctx.send(
             Language.get("moderation.role_not_found",
                          ctx).format(mute_role_name))
         return
     try:
         await user.remove_roles(user,
                                 mute_role,
                                 reason=Language.get(
                                     "moderation.unmuted_by",
                                     ctx).format(ctx.author))
         await ctx.send(
             Language.get("moderation.unmute_success", ctx).format(user))
     except discord.errors.Forbidden:
         if mute_role.position == ctx.me.top_role.position:
             await ctx.send(
                 Language.get("moderation.no_unmute_highest_role", ctx))
         elif mute_role.position > ctx.me.top_role.position:
             await ctx.send(
                 Language.get("moderation.no_unmute_higher_role", ctx))
         else:
             await ctx.send(
                 Language.get("moderation.no_manage_role_perms", ctx))
Esempio n. 49
0
 async def removerole(self, ctx, user: discord.Member, *, name: str):
     """Removes the specified role from the specified user"""
     role = discord.utils.get(ctx.guild.roles, name=name)
     if role is None:
         await ctx.send(
             Language.get("moderation.role_not_found", ctx).format(name))
         return
     try:
         await user.remove_roles(role,
                                 reason=Language.get(
                                     "moderation.removerole_reason",
                                     ctx).format(role.name, ctx.author))
         await ctx.send(
             Language.get("moderation.remove_role_success",
                          ctx).format(name, user))
     except discord.errors.Forbidden:
         if role.position == ctx.me.top_role.position:
             await ctx.send(
                 Language.get("moderation.no_removerole_highest_role", ctx))
         elif role.position > ctx.me.top_role.position:
             await ctx.send(
                 Language.get("moderation.no_removerole_higher_role", ctx))
         else:
             await ctx.send(
                 Language.get("moderation.no_manage_role_perms", ctx))
Esempio n. 50
0
async def on_command_error(ctx, error):
    if isinstance(error, commands.CommandNotFound):
        return
    if isinstance(error, commands.DisabledCommand):
        await ctx.send(Language.get("bot.errors.disabled_command", ctx))
        return
    if isinstance(error, checks.owner_only):
        await ctx.send(Language.get("bot.errors.owner_only", ctx))
        return
    if isinstance(error, checks.dev_only):
        await ctx.send(Language.get("bot.errors.dev_only", ctx))
        return
    if isinstance(error, checks.support_only):
        await ctx.send(Language.get("bot.errors.support_only", ctx))
        return
    if isinstance(error, checks.not_nsfw_channel):
        await ctx.send(Language.get("bot.errors.not_nsfw_channel", ctx))
        return
    if isinstance(error, checks.not_guild_owner):
        await ctx.send(Language.get("bot.errors.not_guild_owner", ctx))
        return
    if isinstance(error, checks.no_permission):
        await ctx.send(Language.get("bot.errors.no_permission", ctx))
        return
    if isinstance(error, commands.NoPrivateMessage):
        await ctx.send(Language.get("bot.errors.no_private_message", ctx))
        return
    if isinstance(ctx.channel, discord.DMChannel):
        await ctx.send(Language.get("bot.errors.command_error_dm_channel",
                                    ctx))
        return

    #In case the bot failed to send a message to the channel, the try except pass statement is to prevent another error
    try:
        await ctx.send(
            Language.get("bot.errors.command_error", ctx).format(error))
    except:
        pass
    log.error("An error occured while executing the {} command: {}".format(
        ctx.command.qualified_name, error))
Esempio n. 51
0
 async def quote(self, ctx, id:int):
     """Quotes a message with the specified message ID"""
     try:
         message = await ctx.channel.fetch_message(id)
     except discord.errors.NotFound:
         await ctx.send(Language.get("bot.no_message_found", ctx).format(id))
         return
     embed = make_message_embed(message.author, message.author.color, message.content, formatUser=True)
     timestamp = message.created_at
     if message.edited_at:
         timestamp = message.edited_at
     embed.timestamp = timestamp
     await ctx.send(embed=embed)
Esempio n. 52
0
 async def banlist(self, ctx):
     """Displays the server's banlist"""
     try:
         banlist = await ctx.guild.bans()
     except discord.errors.Forbidden:
         await ctx.send(Language.get("moderation.no_ban_perms", ctx))
         return
     bancount = len(banlist)
     display_bans = []
     bans = None
     if bancount == 0:
         bans = Language.get("moderation.no_bans", ctx)
     else:
         for ban in banlist:
             if len(", ".join(display_bans)) < 1800:
                 display_bans.append(str(ban.user))
             else:
                 bans = ", ".join(display_bans) + Language.get("moderation.banlist_and_more", ctx).format(len(banlist) - len(display_bans))
                 break
     if not bans:
         bans = ", ".join(display_bans)
     await ctx.send(Language.get("moderation.banlist", ctx).format(bancount, bans))
Esempio n. 53
0
 async def gelbooru(self, ctx, *, tags:str):
     """Searches gelbooru.com for the specified tagged images"""
     await ctx.channel.trigger_typing()
     try:
         data = json.loads(requests.get("https://gelbooru.com/index.php?page=dapi&s=post&q=index&json=1&limit={}&tags={}".format(limit, tags)).text)
     except json.JSONDecodeError:
         await ctx.send(Language.get("nsfw.no_results_found", ctx).format(tags))
         return
     count = len(data)
     if count == 0:
         await ctx.send(Language.get("nsfw.no_results_found", ctx).format(tags))
         return
     image_count = 4
     if count < 4:
         image_count = count
     images = []
     for i in range(image_count):
         try:
             images.append("{}".format(data[random.randint(0, count)]["file_url"]))#http isn't needed
         except KeyError:
             await ctx.send(data["message"])
             return
     await ctx.send(Language.get("nsfw.results", ctx).format(image_count, count, tags, "\n".join(images)))
Esempio n. 54
0
 async def danbooru(self, ctx, *, tags:str):
     """Searches danbooru.donmai.us for the specified tagged images"""
     await ctx.channel.trigger_typing()
     try:
         data = requests.get("https://danbooru.donmai.us/post/index.json?limit={}&tags={}".format(limit, tags), headers=header).json()
     except json.JSONDecodeError:
         await ctx.send(Language.get("nsfw.no_results_found", ctx).format(tags))
         return
     count = len(data)
     if count == 0:
         await ctx.send(Language.get("nsfw.no_results_found", ctx).format(tags))
         return
     image_count = 4
     if count < 4:
         image_count = count
     images = []
     for i in range(image_count):
         try:
             images.append(data[random.randint(0, count)]["file_url"])
         except KeyError:
             await ctx.send(data["message"])
             return
     await ctx.send(Language.get("nsfw.results", ctx).format(image_count, count, tags, "\n".join(images)))
Esempio n. 55
0
 async def userinfo(self, ctx, *, user:discord.Member=None):
     """Gets your information or the information of the specified user"""
     if user is None:
         user = ctx.author
     game = None
     if user.activity:
         game = user.activity.name
     voice_channel = None
     self_mute = False
     self_deaf = False
     server_mute = False
     server_deaf = False
     if user.voice:
         voice_channel = user.voice.channel
         self_mute = user.voice.self_mute
         self_deaf = user.voice.self_deaf
         server_mute = user.voice.mute
         server_deaf = user.voice.deaf
     fields = {Language.get("information.id", ctx):user.id, Language.get("information.bot_account", ctx):user.bot, Language.get("information.created_on", ctx):format_time(user.created_at), Language.get("information.game", ctx):game, Language.get("information.status", ctx):user.status, Language.get("information.role_count", ctx):len(user.roles), Language.get("information.joined_on", ctx):format_time(user.joined_at), Language.get("information.nickname", ctx):user.nick, Language.get("information.voice_channel", ctx):voice_channel, Language.get("information.self_muted", ctx):self_mute, Language.get("information.self_deafened", ctx):self_deaf, Language.get("information.server_muted", ctx):server_mute, Language.get("information.server_deafened", ctx):server_deaf}
     embed = make_list_embed(fields)
     embed.title = str(user)
     embed.color = user.color
     embed.set_thumbnail(url=get_avatar(user))
     await ctx.send(embed=embed)
Esempio n. 56
0
 async def xbooru(self, ctx, *, tags: str):
     """Searches xbooru.com for the specified tagged images"""
     await ctx.channel.trigger_typing()
     try:
         data = requests.get("https://xbooru.com/index.php?page=dapi&s=post&q=index&json=1&limit={}&tags={}".format(limit, tags),  headers=header).json()
     except json.JSONDecodeError:
         await ctx.send(Language.get("nsfw.no_results_found", ctx).format(tags))
         return
     count = len(data)
     if count == 0:
         await ctx.send(Language.get("nsfw.no_results_found", ctx).format(tags))
         return
     image_count = 4
     if count < 4:
         image_count = count
     images = []
     for i in range(image_count):
         try:
             post = data[random.randint(0, count)]
             images.append("http://img3.xbooru.com/images/{}/{}".format(post["directory"], post["image"]))
         except KeyError:
             await ctx.send(data["message"])
             return
     await ctx.send(Language.get("nsfw.results", ctx).format(image_count, count, tags, "\n".join(images)))