@@ -0,0 +1,86 @@ | |||
import discord | |||
import checks | |||
from discord.ext.commands import bot, group | |||
class Admin(): | |||
""" | |||
Admin Commands for those admins | |||
""" | |||
def __init__(self, Bot): | |||
self.bot = Bot | |||
@checks.is_owner_or_admin() | |||
@bot.command(pass_context=True) | |||
async def emojiuse(self, ctx, emoji, *args): | |||
# Flag Parsing | |||
if "-v" in args: | |||
verbose = True | |||
else: | |||
verbose = False | |||
if "-w" in args or emoji == "-w": # Second check just in case user just puts ";emojiuse -w" | |||
all_emojis = True | |||
else: | |||
all_emojis = False | |||
# Functions | |||
def sum(usage): | |||
amount = 0 | |||
for channel in usage.values(): | |||
amount += channel | |||
return amount | |||
def verbose_output(usage): | |||
output = "" | |||
for channel in usage: | |||
channel = self.bot.get_channel(channel) # Convert channel from ID to channel object to get name | |||
output = output + "{}: {} \n".format(channel.name, usage[channel.id]) | |||
return output | |||
async def count_uses(): | |||
usage = {} | |||
for channel in ctx.message.server.channels: | |||
if channel.type == discord.ChannelType.text: # Only looks at server's text channels | |||
x = 0 | |||
async for message in self.bot.logs_from(channel, limit=20000): | |||
if str(emoji) in message.content: | |||
x += 1 | |||
usage[channel.id] = x | |||
else: | |||
pass | |||
return usage | |||
# Command | |||
await self.bot.say("Warning! This command may take upto 5 minutes to process. Please do no spam me. I am working.", delete_after=20) | |||
await self.bot.send_typing(ctx.message.channel) | |||
if all_emojis: | |||
emoji_usage = {} | |||
for emoji in ctx.message.server.emojis: | |||
emoji_usage[emoji.id] = await count_uses() | |||
em = discord.Embed() | |||
for emoji in emoji_usage: | |||
emoji_obj = discord.utils.get(ctx.message.server.emojis, id=emoji) | |||
em.add_field(name=str(emoji_obj), value=sum(emoji_usage[emoji])) | |||
return await self.bot.say(embed=em) | |||
else: | |||
usage = await count_uses() | |||
if verbose: | |||
amount = sum(usage) | |||
output = verbose_output(usage) | |||
output_em = discord.Embed(description = output) | |||
return await self.bot.say(content = "{} has been used {} time(s). Here is the break down per channel.".format(emoji, amount), embed=output_em) | |||
else: # Non-verbose output | |||
amount = sum(usage) | |||
return await self.bot.say("{} has been used {} time(s) server wide.".format(emoji, amount)) | |||
def setup(Bot): | |||
Bot.add_cog(Admin(Bot)) |
@@ -1,4 +1,5 @@ | |||
cogs = [ | |||
"cogs.admin", | |||
"cogs.fun", | |||
"cogs.customcommands", | |||
"cogs.joinleave", |
@@ -3,5 +3,5 @@ __description__ = """RoxBot, A Discord Bot made by a filthy Mercy Main. Built wi | |||
[Github link](https://github.com/RainbowDinoaur/roxbot) | |||
[Changelog](https://github.com/RainbowDinoaur/roxbot#v100)""" | |||
__author__ = "Roxanne Gibson" | |||
__version__= "1.2.2" | |||
__version__= "1.3.0" | |||
embedcolour = 0xDEADBF |
@@ -32,7 +32,8 @@ class ServerConfig(): | |||
"role": "" | |||
}, | |||
"nsfw": { | |||
"enabled": 0 | |||
"enabled": 0, | |||
"channels": [] | |||
}, | |||
"perm_roles": { | |||
"admin": [], |
@@ -1 +1 @@ | |||
{"304048071963312130": {"greets": {"enabled": 0, "welcome-channel": "", "member-role": "", "custom-message": "hellow", "default-message": "Be sure to read the rules."}, "goodbyes": {"enabled": 0, "goodbye-channel": ""}, "self_assign": {"enabled": 0, "roles": []}, "twitch": {"enabled": 0, "twitch-channel": "", "whitelist": {"enabled": 0, "list": []}}, "mute": {"role": "", "admin-role": []}, "nsfw": {"enabled": 0}, "admin_role": {"role": ""}, "custom_commands": {"0": {"test": "\"testedit\"", "hello": "<:tingles:346838411639914506>", "benis": "\ud83c\udd71enis", "sophie": "<@136619052994002944>", "myra": "<@342213251372941312>", "roxieee": "<@!142735312626515979>", "customs": "\"\ud83d\udec3\"", "zzz": "\ud83d\udca4", "lewd!": "\ud83d\udea8 lewd! \ud83d\udea8"}, "1": {}}, "perm_roles": {"admin": [], "mod": []}, "gss": {"logging_channel": "339201847678074880", "required_days": "5", "required_score": "3000000", "log_channel": ""}}} | |||
{"304048071963312130": {"greets": {"enabled": 0, "welcome-channel": "", "member-role": "", "custom-message": "hellow", "default-message": "Be sure to read the rules."}, "goodbyes": {"enabled": 0, "goodbye-channel": ""}, "self_assign": {"enabled": 0, "roles": []}, "twitch": {"enabled": 0, "twitch-channel": "", "whitelist": {"enabled": 0, "list": []}}, "mute": {"role": "", "admin-role": []}, "nsfw": {"enabled": 0, "channels": []}, "admin_role": {"role": ""}, "custom_commands": {"0": {"test": "\"testedit\"", "hello": "<:tingles:346838411639914506>", "benis": "\ud83c\udd71enis", "sophie": "<@136619052994002944>", "myra": "<@342213251372941312>", "roxieee": "<@!142735312626515979>", "customs": "\"\ud83d\udec3\"", "zzz": "\ud83d\udca4", "lewd!": "\ud83d\udea8 lewd! \ud83d\udea8"}, "1": {}}, "perm_roles": {"admin": [], "mod": []}, "gss": {"logging_channel": "339201847678074880", "required_days": "5", "required_score": "3000000", "log_channel": ""}}, "395632940328943616": {"greets": {"enabled": 0, "welcome-channel": "", "member-role": "", "custom-message": "", "default-message": "Be sure to read the rules."}, "goodbyes": {"enabled": 0, "goodbye-channel": ""}, "self_assign": {"enabled": 0, "roles": []}, "twitch": {"enabled": 0, "twitch-channel": "", "whitelist": {"enabled": 0, "list": []}}, "mute": {"role": ""}, "nsfw": {"enabled": 0, "channels": []}, "perm_roles": {"admin": [], "mod": []}, "custom_commands": {"0": {}, "1": {}}, "gss": {"log_channel": "", "required_days": "", "required_score": ""}}} |