1
|
|
|
""" |
2
|
|
|
Cog with general commands available in the Bot. |
3
|
|
|
|
4
|
|
|
Current commands: |
5
|
|
|
/ping - check Bot latency |
6
|
|
|
/clear - clear x messages on the channel |
7
|
|
|
/exit | !exit - end Bot's runtime and disconnect from the server |
8
|
|
|
/warn - warn @user with reason |
9
|
|
|
/warns - send @user warns to author's DM |
10
|
|
|
/nword - Changes N-Word killed channel name - UNSTABLE |
11
|
|
|
/updatetotmem - Update #TotalMembers channel |
12
|
|
|
/updatecommon - Update common spotting channel with new monster name |
13
|
|
|
/tba |
14
|
|
|
""" |
15
|
|
|
import discord |
16
|
|
|
from discord.utils import get |
17
|
|
|
from googletrans import Translator |
18
|
|
|
import cogs.cogbase as cogbase |
19
|
|
|
from discord.ext import commands |
20
|
|
|
from discord_slash import cog_ext, SlashContext |
21
|
|
|
from cogs.databasecog import DatabaseCog |
22
|
|
|
from cogs.leaderboardcog import legend_multiplier |
23
|
|
|
|
24
|
|
|
|
25
|
|
|
class CommandsCog(cogbase.BaseCog): |
26
|
|
|
def __init__(self, base): |
27
|
|
|
super().__init__(base) |
28
|
|
|
|
29
|
|
|
# Get own spotting stats |
30
|
|
|
@cog_ext.cog_slash(name="myStats", guild_ids=cogbase.GUILD_IDS, |
31
|
|
|
description="Get your spot stats", |
32
|
|
|
default_permission=True) |
33
|
|
|
async def get_stats(self, ctx): |
34
|
|
|
spot_roles = self.bot.config["total_milestones"][0] |
35
|
|
|
guild = self.bot.get_guild(self.bot.guild[0]) |
36
|
|
|
spots_df = await DatabaseCog.db_get_member_stats(ctx.author.id) |
37
|
|
|
spots_df["total"] = spots_df["legendary"] * legend_multiplier + spots_df["rare"] |
38
|
|
|
|
39
|
|
|
role_new = "" |
40
|
|
|
spots_for_new = -1 |
41
|
|
|
roles_list = [key for (key, value) in spot_roles.items() if spots_df.at[0, "total"] < value] |
42
|
|
|
values_list = [value for (key, value) in spot_roles.items() if spots_df.at[0, "total"] < value] |
43
|
|
|
if roles_list: |
44
|
|
|
role_new = get(guild.roles, name=roles_list[0]) |
45
|
|
|
spots_for_new = values_list[0] |
46
|
|
|
|
47
|
|
|
message = f"**Legends**: {spots_df.at[0, 'legendary']}\n" \ |
48
|
|
|
f"**Rares**: {spots_df.at[0, 'rare']}\n" \ |
49
|
|
|
f"**Commons**: {spots_df.at[0, 'common']}\n\n" \ |
50
|
|
|
f"**Total points**: {spots_df.at[0, 'total']}\n" \ |
51
|
|
|
f"**Progress**: {spots_df.at[0, 'total']}/{spots_for_new}\n" \ |
52
|
|
|
f"**Next role**: _{role_new}_" |
53
|
|
|
|
54
|
|
|
await ctx.send(f"{ctx.author.mention} stats:\n{message}", hidden=True) |
55
|
|
|
|
56
|
|
|
# Pool |
57
|
|
|
@cog_ext.cog_slash(name="poll", guild_ids=cogbase.GUILD_IDS, |
58
|
|
|
description="Create pool", |
59
|
|
|
permissions=cogbase.PERMISSION_MODS) |
60
|
|
|
async def poll(self, ctx, *, poll_info): |
61
|
|
|
emb = (discord.Embed(description=poll_info, colour=0x36393e)) |
62
|
|
|
emb.set_author(name=f"Poll by {ctx.author.display_name}") |
63
|
|
|
try: |
64
|
|
|
poll_message = await ctx.send(embed=emb) |
65
|
|
|
await poll_message.add_reaction("\N{THUMBS UP SIGN}") |
66
|
|
|
await poll_message.add_reaction("\N{THUMBS DOWN SIGN}") |
67
|
|
|
except Exception as e: |
68
|
|
|
await ctx.send(f"Oops, I couldn't react to the poll. Check that I have permission to add reactions! " |
69
|
|
|
f"```py\n{e}```") |
70
|
|
|
|
71
|
|
|
# Translate |
72
|
|
|
@cog_ext.cog_slash(name="translate", guild_ids=cogbase.GUILD_IDS, |
73
|
|
|
description="Translate message", |
74
|
|
|
permissions=cogbase.PERMISSION_MODS) |
75
|
|
|
async def translate(self, ctx: SlashContext, message: str): |
76
|
|
|
# Translates the language and converts it to English |
77
|
|
|
translator = Translator() |
78
|
|
|
translated_message = translator.translate(message) |
79
|
|
|
await ctx.send(f"`{message}` -> `{translated_message.text}`", hidden=True) |
80
|
|
|
|
81
|
|
|
|
82
|
|
|
def setup(bot: commands.Bot): |
83
|
|
|
bot.add_cog(CommandsCog(bot)) |
84
|
|
|
|