Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@commands.command(name="schema")
async def broken(self, ctx):
await ctx.send("Sorry, I'm a broken schema!")
@commands.command(name='token')
@checks.spam_check()
async def _token(self, ctx):
token = ctx.message.content.split(' ', 1)[1]
auth = base64.b64encode(bytes(':'.join([self.config.tokens['client_id'], self.config.tokens['secret']]),
'utf-8'))
access_token = await self.bot.esi_data.refresh_access_token(token, auth)
try:
verify = await self.bot.esi_data.verify_token(access_token['access_token'])
character_id = verify['CharacterID']
except:
return await ctx.send("ERROR: That is not a valid refresh token.")
expires = float(access_token['expires_in']) + time.time()
sql = ''' REPLACE INTO access_tokens(character_id,discord_id,refresh_token,access_token,expires)
VALUES(?,?,?,?,?) '''
values = (character_id, ctx.author.id, token, access_token['access_token'], expires)
await db.execute_sql(sql, values)
@commands.command(pass_context=True, no_pm=True)
async def cgames(self, ctx):
"""Shows the currently most played games"""
server = ctx.message.server
members = server.members
freq_list = {}
for member in members:
if member.game is not None:
if member.game.name not in freq_list:
freq_list[member.game.name] = 0
freq_list[member.game.name]+=1
sorted_list = sorted(freq_list.items(), key=operator.itemgetter(1))
await self.bot.say(sorted_list)
if not freq_list:
@commands.command(pass_context=True, no_pm=True)
@checks.admin_or_permissions(manage_server=True)
async def enable(self, ctx, *, command: str):
"""Enables a command for this server.
You must have Manage Server permissions or the
Bot Admin role to use this command.
"""
command = command.lower()
guild_id = ctx.message.server.id
entries = self.config.get(guild_id, {})
try:
entries.pop(command)
except KeyError:
await self.bot.say('The command does not exist or is not disabled.')
else:
@commands.command(hidden=True)
async def eval(self, ctx, *, body: str):
"""Evaluates a code"""
env = {
'discord': discord,
'bot': self.bot,
'ctx': ctx,
'channel': ctx.channel,
'author': ctx.author,
'guild': ctx.guild,
'message': ctx.message
}
env.update(globals())
body = self.cleanup_code(body)
@commands.command()
async def info(self, ctx: commands.Context):
"""Shows info about the bot"""
em = discord.Embed(title="uBot",
colour=discord.Colour.gold())
em.add_field(name="Creator", value="arielbeje - <@114814850621898755>")
em.add_field(name="Source", value="[GitHub](https://github.com/arielbeje/uBot)")
em.add_field(name="Invite link", value="[Link](https://discordapp.com/oauth2/authorize?&client_id=334003132583510016&scope=bot&permissions=0)")
await ctx.send(embed=em)
@commands.command(aliases = ['q'])
async def quote(self, ctx, msg_id: int, *, reply = None):
if ctx.guild.id in del_commands:
try:
await ctx.message.delete()
except discord.Forbidden:
pass
message = None
async with ctx.channel.typing():
async for msg in ctx.channel.history(limit = 1000, before = ctx.message):
perms = ctx.guild.me.permissions_in(ctx.channel)
if not perms.read_messages or not perms.read_message_history:
break
if msg.id == msg_id:
message = msg
break
@commands.command(no_pm=True, pass_context=True)
@checks.admin_or_permissions(ban_members=True)
async def softban(self, ctx, user: discord.Member, *, reason: str = None):
"""Kicks the user, deleting 1 day worth of messages."""
server = ctx.message.server
channel = ctx.message.channel
can_ban = channel.permissions_for(server.me).ban_members
author = ctx.message.author
if author == user:
await self.bot.say("I cannot let you do that. Self-harm is "
"bad \N{PENSIVE FACE}")
return
elif not self.is_allowed_by_hierarchy(server, author, user):
await self.bot.say("I cannot let you do that. You are "
"not higher than the user in the role "
"hierarchy.")
@commands.command(aliases=["rollthedice", "dice", "roll"])
async def rtd(self, ctx, *dice: str):
"""Roll a number of dice with given sides (ndx notation)
Example: rp!rtd 3d7 2d4
Optional Additions:
Test for success by adding a >/<#
Grab the top n rolls by adding ^n
Add to the final roll by just adding a number (pos or neg)
Examples of all:
rp!rtd 8d8 -12 15 ^4 >32
-> Roll failed (30 > 32) ([8 + 7 + 6 + 6] + -12 + 15) (Grabbed top 4 out of 8)"""
try:
dice = list(dice)
rolls = dict()
add = []
@commands.command()
async def channelinfo(self, ctx: NabCtx, channel: discord.TextChannel = None):
"""Shows information about a channel.
If no channel is specified, the information for the current channel is shown."""
if channel is None:
channel = ctx.channel
if not channel.permissions_for(ctx.author).read_messages:
return await ctx.error("You are not supposed to see that channel, so I can't show you anything.")
embed = discord.Embed(title=f"#{channel}", description=f"**ID** {channel.id}", colour=discord.Colour.blurple(),
timestamp=channel.created_at)
if channel.topic:
embed.description += f"\n{channel.topic}"
embed.add_field(name="Visible by", value=f"{len(channel.members):,} members")
embed.add_field(name="Mention", value=f"`{channel.mention}`")
embed.add_field(name="NSFW", value=ctx.tick(channel.nsfw))
embed.set_footer(text="Created on")