-
Notifications
You must be signed in to change notification settings - Fork 0
/
fixme-dev.py
129 lines (107 loc) · 6.25 KB
/
fixme-dev.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import discord
from discord.ext import commands
import time
# Developer cog: For developer commands such as restarting the bot or changing it's custom rich presence
class Developer(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.status_types = {
"online": discord.Status.online,
"dnd": discord.Status.dnd,
"idle": discord.Status.idle,
"invisible": discord.Status.invisible
}
self.activity_types = {
"playing": discord.ActivityType.playing,
"streaming": discord.ActivityType.streaming,
"listening to": discord.ActivityType.listening,
"watching": discord.ActivityType.watching,
"competing in": discord.ActivityType.competing
}
@discord.slash_command(description="Checks whether you are a CASbot developer or not")
async def checkowner(self, interaction: discord.Interaction):
if await self.bot.is_owner(interaction.user):
await interaction.response.send_message(":white_check_mark: You are a CASbot owner!")
else:
await interaction.response.send_message(":x: You are not a CASbot owner.")
@discord.slash_command(description="Spams a message - Dev Only")
async def spam(
self,
interaction: discord.Interaction,
times: int = discord.SlashOption(name="times", description="How many times to repeat the message 1 10000", required=True),
delay: float = discord.SlashOption(name="delay", description="How long to wait between each message 0 60 secs", required=True),
content: str = discord.SlashOption(name="content", description="Text to send", required=True)
):
if await self.bot.is_owner(interaction.user):
print(f"CASBOT: Spamming \"{content}\" {times} times with a delay of {delay} seconds")
await interaction.response.send_message(":white_check_mark: Sending your message(s)!")
for i in range(times):
await interaction.channel.send(content)
time.sleep(delay)
else:
print(f"CASBOT: /spam denied user")
await interaction.response.send_message(":x: Sorry, you do not have permission to use this command.")
@discord.slash_command(description="CASbot Developer commands")
async def dev(self, interaction: discord.Interaction):
None
# @dev.subcommand(description="Change the bot's prescence - Dev Only")
# async def presence(
# self,
# interaction: discord.Interaction,
# status_type: str = discord.SlashOption(name="statustype", description="Choose the status type for the bot", required=True, choices=["online", "dnd", "idle", "invisible"]),
# activity_type: str = discord.SlashOption(name="activitytype", description="Choose the activity type for the bot", required=True, choices=["playing", "streaming", "listening to", "watching", "competing in"]),
# activity_name: str = discord.SlashOption(name="activityname", description="Specify the custom activity name", required=True)
# ):
# if await self.bot.is_owner(interaction.user):
# print(f"CASBOT: Changing presence to {activity_type} {activity_name} ({status_type})")
# await self.bot.change_presence(status=self.status_types[status_type], activity=discord.Activity(name=activity_name, type=self.activity_types[activity_type]))
# await interaction.response.send_message(f":white_check_mark: Activity successfully set to **{activity_type} {activity_name}** ({status_type}).")
# ref = self.db.reference("/casbot/data/presence/")
# ref.child("statusType").set(status_type)
# ref.child("activityType").set(activity_type)
# ref.child("activityValue").set(activity_name)
# else:
# print(f"CASBOT: /dev presence denied user")
# await interaction.response.send_message(":x: Sorry, you do not have permission to use this command.")
@dev.subcommand(description="Shuts down or restarts the bot - Dev Only")
async def shutdown(self, interaction: discord.Interaction):
if await self.bot.is_owner(interaction.user):
print(f"CASBOT: RECEIVED SHUTDOWN COMMAND")
await interaction.response.send_message(":white_check_mark: Shutting down...")
await self.bot.close()
else:
print(f"CASBOT: /dev shutdown command denied user")
await interaction.response.send_message(":x: You are not a CASbot owner.")
@dev.subcommand(description="Makes a poll - Dev Only")
async def poll(
self,
interaction: discord.Interaction,
poll_content: str = discord.SlashOption(name="content", description="Poll content", required=True),
ping_role: discord.Role = discord.SlashOption(name="role", description="Role to ping", required=False)
):
if await self.bot.is_owner(interaction.user):
print(f"CASBOT: Making poll...")
if not ping_role:
ping = ""
else:
ping = f"<@&{ping_role.id}> "
poll_message = await interaction.channel.send(ping+poll_content)
await poll_message.add_reaction("<:YES:976172480160997476>")
await poll_message.add_reaction("<:NO:976172479687045141>")
await interaction.response.send_message(":white_check_mark: Poll sent!", ephemeral=True)
else:
print(f"CASBOT: /poll denied user")
await interaction.response.send_message(":x: You are not a CASbot owner.")
@dev.subcommand(description="Sends a message via the debug webhook - Dev Only")
async def webhook(
self,
interaction: discord.Interaction,
message: str = discord.SlashOption(name="message", description="Message to send", required=True)
):
if await self.bot.is_owner(interaction.user):
print(f"CASBOT: Sent {message} through debug webhook")
self.debug.send(f"**CASbot: {message}")
await interaction.response.send_message(f":white_check_mark: Sent message \"{message}\" through debug webhook.")
else:
print(f"CASBOT: /dev webhook denied user")
await interaction.response.send_message(":x: You are not a CASbot owner.")