Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@checks.mod_or_permissions(manage_messages=True)
async def audioset_volume(self, ctx, percent: int=None):
"""Sets the volume (0 - 100)
Note: volume may be set up to 200 but you may experience clipping."""
server = ctx.message.server
if percent is None:
vol = self.get_server_settings(server)['VOLUME']
msg = "Volume is currently set to %d%%" % vol
elif percent >= 0 and percent <= 200:
self.set_server_setting(server, "VOLUME", percent)
msg = "Volume is now set to %d." % percent
if percent > 100:
msg += ("\nWarning: volume levels above 100 may result in"
" clipping")
# Set volume of playing audio
vc = self.voice_client(server)
@checks.mod_or_permissions()
async def givemoney(self, ctx, guild_name: str, amount: NumberConverter):
"""Deposit an amount of money into the bank of a guild. Does not take from user's bank.
Example: rp!guild givemoney MyGuild 500
Requires Bot Moderator or Bot Admin"""
async with self.bot.di.rm.lock(ctx.guild.id):
amount = abs(amount)
guilds = await self.bot.di.get_guild_guilds(ctx.guild)
guild = guilds.get(guild_name)
if guild is None:
await ctx.send(await _(ctx, "That guild is invalid!"))
return
guild.bank += amount
@checks.mod_or_permissions(manage_messages=True)
async def prune(self, ctx, number: int):
"""Deletes the specified amount of messages."""
if ctx.invoked_subcommand is None:
channel = ctx.message.channel
author = ctx.message.author
server = author.server
is_bot = self.bot.user.bot
has_permissions = channel.permissions_for(server.me).manage_messages
to_delete = []
if not has_permissions:
await self.bot.say("I'm not allowed to delete messages.")
return
async for message in self.bot.logs_from(channel, limit=number+1):
@checks.mod_or_permissions()
@settings.command()
@checks.no_pm()
async def additem(self, ctx, *, name: str):
"""Add a custom item.
Custom keys that can be used for special additions:
`image` Setting this to a URL will give that item a special thumbnail when info is viewed for it
`used` A message for when the item is used
Henry: rp!settings additem Example
RPGBot: Describe the item (a description for the item)
Henry: This is an example item
RPGBot: Additional information? (Attributes formatted in a list i.e color: 400, value: 200 Set an image for this item with the image key i.e. image: http://image.com/image.png Set this item as usable by adding used key i.e. used: You open the jar and the bird flies away
Henry: used: You used this item!, image: http://www.sourcecertain.com/img/Example.png
RPGBot: Item successfully created
Requires Bot Moderator or Bot Admin
@checks.mod_or_permissions(administrator=True)
@mute.command(name="server", pass_context=True, no_pm=True)
async def server_mute(self, ctx, user : discord.Member, *, reason: str = None):
"""Mutes user in the server"""
author = ctx.message.author
server = ctx.message.server
if 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.")
return
register = {}
for channel in server.channels:
if channel.type != discord.ChannelType.text:
continue
@checks.mod_or_permissions(manage_channels=True)
async def setreee(self, ctx):
server = ctx.message.server
if server.id not in self.settings:
self.settings.append(server.id)
await self.bot.say("REEE images will now be posted in {}!".format(server.name))
elif server.id in self.settings:
self.settings.remove(server.id)
await self.bot.say("REEE images will no longer be posted in {}!".format(server.name))
dataIO.save_json("data/reee/settings.json", self.settings)
@checks.mod_or_permissions(kick_members=True)
async def activity(self, ctx):
"""Setup an activity checker channel"""
if ctx.invoked_subcommand is None:
await self.bot.send_cmd_help(ctx)
@checks.mod_or_permissions(ban_members=True)
async def hackban(self, ctx, user_id: int):
"""Bans a member by their ID.
- user_id: The user ID to ban
"""
try:
await self.liara.http.ban(str(user_id), str(ctx.guild.id))
await ctx.send('Done. Good riddance.')
except discord.NotFound:
await ctx.send('That user doesn\'t exist.')
except discord.Forbidden:
await ctx.send('Sorry, I don\'t have permission to ban that person here.')
except discord.HTTPException:
await ctx.send('That ID is invalid.')
@checks.mod_or_permissions(manage_server=True)
async def _del_alias(self, ctx, command):
"""Deletes an alias"""
command = command.lower()
server = ctx.message.server
if server.id in self.aliases:
self.aliases[server.id].pop(command, None)
dataIO.save_json(self.file_path, self.aliases)
await self.bot.say("Alias '{}' deleted.".format(command))
@checks.mod_or_permissions()
async def removeitem(self, ctx, *, name: str):
"""Remove a listed item
Example: `rp!shop remove Pokeball`
Requires Bot Moderator or Bot Admin"""
async with self.bot.di.rm.lock(ctx.guild.id):
shop = await self.bot.di.get_guild_shop(ctx.guild)
try:
del shop[name]
except KeyError:
await ctx.send(await _(ctx, "That item isn't listed!"))
return
await self.bot.di.update_guild_shop(ctx.guild, shop)
await ctx.send(await _(ctx, "Successfully removed item"))