Skip to content

Commit 315d161

Browse files
committed
begin to migrate to pycord (stats is only partially done and still does not work)
1 parent 653aeda commit 315d161

File tree

29 files changed

+416
-418
lines changed

29 files changed

+416
-418
lines changed

index.py

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import utils.log as Log
2-
import disnake
3-
from disnake.ext import commands, tasks
2+
import discord
3+
from discord.ext import commands, tasks
44
from bottoken import TOKEN
55
import variables
66
import time
@@ -11,81 +11,81 @@
1111

1212

1313
# Setup bot
14-
bot = commands.InteractionBot(
14+
bot = commands.Bot(
1515
test_guilds=[variables.guild],
16-
intents=disnake.Intents.all(),
16+
intents=discord.Intents.all(),
1717
)
1818

1919
# Logs
20-
from modules.logs.listeners import LogsListeners
21-
bot.add_cog(LogsListeners(bot))
20+
# from modules.logs.listeners import LogsListeners
21+
# bot.add_cog(LogsListeners(bot))
2222

2323
# Moderation
24-
from modules.moderation.listeners import ModerationListeners
25-
bot.add_cog(ModerationListeners(bot))
26-
from modules.moderation.commands.mod import ModCommand
27-
bot.add_cog(ModCommand(bot))
28-
from modules.moderation.message_commands.moderate import ModerateCommand
29-
bot.add_cog(ModerateCommand(bot))
30-
from modules.moderation.message_commands.report import ReportCommand
31-
bot.add_cog(ReportCommand(bot))
24+
# from modules.moderation.listeners import ModerationListeners
25+
# bot.add_cog(ModerationListeners(bot))
26+
# from modules.moderation.commands.mod import ModCommand
27+
# bot.add_cog(ModCommand(bot))
28+
# from modules.moderation.message_commands.moderate import ModerateCommand
29+
# bot.add_cog(ModerateCommand(bot))
30+
# from modules.moderation.message_commands.report import ReportCommand
31+
# bot.add_cog(ReportCommand(bot))
3232

3333
# Help Channels
34-
from modules.help_channels.listeners import HelpChannelListeners
35-
bot.add_cog(HelpChannelListeners(bot))
36-
from modules.help_channels.commands.resolve import ResolveCommand
37-
bot.add_cog(ResolveCommand(bot))
38-
from modules.help_channels.commands.summon import SummonCommand
39-
bot.add_cog(SummonCommand(bot))
40-
from modules.help_channels.commands.top import TopCommand
41-
bot.add_cog(TopCommand(bot))
42-
from modules.help_channels.message_commands.redirect import RedirectCommand
43-
bot.add_cog(RedirectCommand(bot))
44-
from modules.help_channels.message_commands.remind import RemindCommand
45-
bot.add_cog(RemindCommand(bot))
34+
# from modules.help_channels.listeners import HelpChannelListeners
35+
# bot.add_cog(HelpChannelListeners(bot))
36+
# from modules.help_channels.commands.resolve import ResolveCommand
37+
# bot.add_cog(ResolveCommand(bot))
38+
# from modules.help_channels.commands.summon import SummonCommand
39+
# bot.add_cog(SummonCommand(bot))
40+
# from modules.help_channels.commands.top import TopCommand
41+
# bot.add_cog(TopCommand(bot))
42+
# from modules.help_channels.message_commands.redirect import RedirectCommand
43+
# bot.add_cog(RedirectCommand(bot))
44+
# from modules.help_channels.message_commands.remind import RemindCommand
45+
# bot.add_cog(RemindCommand(bot))
4646

4747
# Utilities
48-
from modules.utilities.commands.members import MembersCommand
49-
bot.add_cog(MembersCommand(bot))
50-
from modules.utilities.commands.help import HelpCommand
51-
bot.add_cog(HelpCommand(bot))
52-
from modules.utilities.commands.icon import IconCommand
53-
bot.add_cog(IconCommand(bot))
54-
from modules.utilities.message_commands.view import ViewFileCommand
55-
bot.add_cog(ViewFileCommand(bot))
48+
# from modules.utilities.commands.members import MembersCommand
49+
# bot.add_cog(MembersCommand(bot))
50+
# from modules.utilities.commands.help import HelpCommand
51+
# bot.add_cog(HelpCommand(bot))
52+
# from modules.utilities.commands.icon import IconCommand
53+
# bot.add_cog(IconCommand(bot))
54+
# from modules.utilities.message_commands.view import ViewFileCommand
55+
# bot.add_cog(ViewFileCommand(bot))
5656

5757
# Fun
58-
from modules.fun.listeners import FunListeners
59-
bot.add_cog(FunListeners(bot))
60-
from modules.fun.commands.suspension import SuspensionRailwayCommand
61-
bot.add_cog(SuspensionRailwayCommand(bot))
62-
from modules.fun.commands.uwu import UwuCommand
63-
bot.add_cog(UwuCommand(bot))
58+
# from modules.fun.listeners import FunListeners
59+
# bot.add_cog(FunListeners(bot))
60+
# from modules.fun.commands.suspension import SuspensionRailwayCommand
61+
# bot.add_cog(SuspensionRailwayCommand(bot))
62+
# from modules.fun.commands.uwu import UwuCommand
63+
# bot.add_cog(UwuCommand(bot))
6464

6565
# Welcome
66-
from modules.welcome.listeners import WelcomeListeners
67-
bot.add_cog(WelcomeListeners(bot))
66+
# from modules.welcome.listeners import WelcomeListeners
67+
# bot.add_cog(WelcomeListeners(bot))
6868

6969
# Events
70-
from modules.events.button_click import OnButtonClick
71-
bot.add_cog(OnButtonClick(bot))
70+
# from modules.events.button_click import OnButtonClick
71+
# bot.add_cog(OnButtonClick(bot))
7272

7373
# Stats
7474
from modules.stats.commands.stats import StatsCommand
7575
bot.add_cog(StatsCommand(bot))
76-
from modules.stats.commands.stats_admin import StatsAdminCommand
77-
bot.add_cog(StatsAdminCommand(bot))
76+
# from modules.stats.commands.stats_admin import StatsAdminCommand
77+
# bot.add_cog(StatsAdminCommand(bot))
7878

7979
# QOTD
80-
from modules.qotd.schedule import schedule_qotd
80+
# from modules.qotd.schedule import schedule_qotd
8181

8282
# Loops
8383
@tasks.loop(minutes=10)
8484
async def ten():
85-
channel_asked: disnake.VoiceChannel = bot.get_channel(variables.stats_asked)
85+
channel_asked: discord.VoiceChannel = bot.get_channel(variables.stats_asked)
8686
total_threads = 0
8787
for i in variables.help_channels:
88-
channel: disnake.ForumChannel = bot.get_channel(i)
88+
channel: discord.ForumChannel = bot.get_channel(i)
8989
questions = len(channel.threads)
9090
archived_qns = await channel.archived_threads(limit=None).flatten()
9191
for _ in channel.threads:
@@ -102,7 +102,7 @@ async def ten():
102102
@tasks.loop(hours=1)
103103
async def autoclose_loop():
104104
for i in variables.help_channels:
105-
forum_channel: disnake.ForumChannel = bot.get_channel(i)
105+
forum_channel: discord.ForumChannel = bot.get_channel(i)
106106
for thread in forum_channel.threads:
107107
last = await thread.history(limit=1).flatten()
108108
last = last[0]
@@ -117,10 +117,10 @@ async def autoclose_loop():
117117
await thread.send("-# Error resolving this thread.")
118118
else:
119119
await thread.send(
120-
embed=disnake.Embed(
120+
embed=discord.Embed(
121121
title="Closed for inactivity",
122122
description="This question has been inactive for some time, so it's going to be closed for inactivity. If you still need it, please disregard this message.",
123-
colour=disnake.Colour.dark_gray(),
123+
colour=discord.Colour.dark_gray(),
124124
).set_footer(text="Any further messages or reactions will re-open this thread.")
125125
)
126126

modules/events/button_click.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import disnake
2-
from disnake.ext import commands
1+
import discord
2+
from discord.ext import commands
33
import variables
44
import datetime
55
import utils.log as Log
@@ -12,15 +12,15 @@ def __init__(self, bot: commands.Bot):
1212
self.bot = bot
1313

1414
@commands.Cog.listener()
15-
async def on_button_click(self, inter: disnake.MessageInteraction):
15+
async def on_button_click(self, inter: discord.MessageInteraction):
1616
if inter.component.custom_id == "resolve_question_button":
1717
role = inter.guild.get_role(variables.helper)
1818
if (inter.channel.owner_id == inter.user.id) or (role in inter.user.roles):
1919
await resolve_thread(inter.channel, inter.response, inter.author)
2020
else:
2121
await inter.response.send_message(
22-
embed=disnake.Embed(
23-
colour=disnake.Colour.red(),
22+
embed=discord.Embed(
23+
colour=discord.Colour.red(),
2424
title="❌ Resolve Help Channel",
2525
description="You can't do this since you are neither a helper nor the owner of this channel!",
2626
),
@@ -46,8 +46,8 @@ async def on_button_click(self, inter: disnake.MessageInteraction):
4646
if time_difference_minutes >= 30 or role in inter.author.roles:
4747
await inter.response.send_message(
4848
f"<@&{variables.helper!s}> <@&{variables.comm_helper_B!s}>",
49-
embed=disnake.Embed(
50-
colour=disnake.Colour.blue(),
49+
embed=discord.Embed(
50+
colour=discord.Colour.blue(),
5151
title=("🙇 Helpers Arise!"),
5252
description=(
5353
"Please note that you still might not immediately get a response since all helpers are human beings and volunteers (and also might be sleeping right now)"
@@ -56,18 +56,18 @@ async def on_button_click(self, inter: disnake.MessageInteraction):
5656
text=("Requested by " + inter.user.name),
5757
icon_url=inter.user.avatar,
5858
),
59-
allowed_mentions=disnake.AllowedMentions(roles=True),
59+
allowed_mentions=discord.AllowedMentions(roles=True),
6060
)
6161

62-
embed = disnake.Embed(
63-
colour=disnake.Colour.orange(),
62+
embed = discord.Embed(
63+
colour=discord.Colour.orange(),
6464
title="Someone will come and help soon!",
6565
description="💬 While you wait, take this time to provide more context and details.\n\n✅ Once your question has been resolved (or you no longer need it), please click Resolve Question or run `/resolve`"
6666
)
67-
resolve_question_button = disnake.ui.Button(
67+
resolve_question_button = discord.ui.Button(
6868
label="Resolve Question",
6969
custom_id="resolve_question_button",
70-
style=disnake.ButtonStyle.green,
70+
style=discord.ButtonStyle.green,
7171
emoji="✅",
7272
)
7373

@@ -78,8 +78,8 @@ async def on_button_click(self, inter: disnake.MessageInteraction):
7878
Log.info(f"{inter.author.name} summoned helpers")
7979

8080
else:
81-
embed = disnake.Embed(
82-
colour=disnake.Colour.red(),
81+
embed = discord.Embed(
82+
colour=discord.Colour.red(),
8383
title="🕑 Be patient!",
8484
description=(
8585
f"Typically, you should get a response within 10 minutes, but our helpers are volunteers. We therefore need you to wait until <t:{int((datetime.datetime.now() + datetime.timedelta(minutes=30 - time_difference_minutes)).timestamp())}:t> before you use this button.\n\nIf nobody has helped you yet, try rephrasing your question, giving more details, or just being patient."
@@ -89,8 +89,8 @@ async def on_button_click(self, inter: disnake.MessageInteraction):
8989

9090
Log.info(f"{inter.author.name} tried to summon helpers, but still has {str(30 - int(time_difference_minutes))} minutes left.")
9191
else:
92-
embed = disnake.Embed(
93-
colour=disnake.Colour.red(),
92+
embed = discord.Embed(
93+
colour=discord.Colour.red(),
9494
title="❌ Summon Helpers",
9595
description="You can't do this since you are neither a helper nor the owner of this channel!",
9696
)
@@ -100,7 +100,7 @@ async def on_button_click(self, inter: disnake.MessageInteraction):
100100
await inter.message.delete()
101101
if inter.component.custom_id == "close_report":
102102
embed = inter.message.embeds[0]
103-
embed.colour = disnake.Colour.blue()
103+
embed.colour = discord.Colour.blue()
104104
embed.title = "Closed Message Report"
105105
embed.add_field("Closed by",f"{inter.author.global_name} ({inter.author.id})",inline=False)
106106

modules/fun/commands/suspension.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import random
22

3-
import disnake
4-
from disnake.ext import commands
3+
import discord
4+
from discord.ext import commands
55

66
IMAGES = [
77
{
@@ -47,23 +47,23 @@ def __init__(self, bot):
4747
self.bot = bot
4848

4949
@commands.slash_command(name="susprail")
50-
async def susprail(self, inter: disnake.ApplicationCommandInteraction):
50+
async def susprail(self, inter: discord.ApplicationContext):
5151
return
5252

5353
@susprail.sub_command("image","Generate a random image of a suspension railway")
54-
async def image(self, inter: disnake.ApplicationCommandInteraction):
54+
async def image(self, inter: discord.ApplicationContext):
5555
image = random.choice(IMAGES)
56-
embed = disnake.Embed(
56+
embed = discord.Embed(
5757
title=image["title"],
58-
colour=disnake.Colour.blue()
58+
colour=discord.Colour.blue()
5959
).set_image(image["url"]).set_footer(text=image["credits"])
6060
await inter.response.send_message(embed=embed)
6161

6262
@susprail.sub_command("info","Learn about suspension railways")
63-
async def info(self, inter: disnake.ApplicationCommandInteraction):
64-
embed = disnake.Embed(
63+
async def info(self, inter: discord.ApplicationContext):
64+
embed = discord.Embed(
6565
title="Learn about Suspension Railways",
66-
colour=disnake.Colour.blue()
66+
colour=discord.Colour.blue()
6767
)
6868
embed.add_field("What are suspension railways?","A suspension railway is a type of elevated monorail. The suspension railway vehicles are suspended from a single, fixed track (not a cable). This makes them good for being built above streets or even other railway types.",inline=False)
6969
embed.add_field("What suspension railways are there?","There are many suspension railways including the following:\n- **Schwebebahn** in Wuppertal, Germany\n- **Schwebebahn** in Dresden, Germany\n- **H-Bahn** in TU Dortmund, Germany\n- **Sky train** in Dusseldorf Airport, Germany\n- **Strela** in Glukhovo , Russia\n- **Shonan** in Kanagawa Prefecture, Japan\n- **Chiba Urban** in Chiba, Japan\n- **SkyTrain** in Chengdu, China\n- **Optics Valley** in Wuhan, China\n- **Red Rail** in Xingguo, China",inline=False)

modules/fun/commands/uwu.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import json
22
from utils.uwufier import Uwuifier
33
import utils.log as Log
4-
import disnake
5-
from disnake.ext import commands
4+
import discord
5+
from discord.ext import commands
66

77
uwu_data = {"users": [], "channels": [], "banned": [], "enabled": True}
88

@@ -11,11 +11,11 @@ def __init__(self, bot):
1111
self.bot = bot
1212

1313
@commands.slash_command(name="uwu")
14-
async def uwu(self, inter: disnake.ApplicationCommandInteraction):
14+
async def uwu(self, inter: discord.ApplicationContext):
1515
return
1616

1717
@uwu.sub_command("message","Send an uwufied message")
18-
async def message(self, inter: disnake.ApplicationCommandInteraction, text: str):
18+
async def message(self, inter: discord.ApplicationContext, text: str):
1919
hooks = await inter.channel.webhooks()
2020

2121
for hook in hooks:
@@ -24,28 +24,28 @@ async def message(self, inter: disnake.ApplicationCommandInteraction, text: str)
2424
else:
2525
hook = await inter.channel.create_webhook(name="DPH")
2626
uwu = Uwuifier()
27-
await hook.send(uwu.uwuify_sentence(text.lower()),wait=False,username=inter.author.display_name,avatar_url=inter.author.display_avatar.url,allowed_mentions=disnake.AllowedMentions.none())
27+
await hook.send(uwu.uwuify_sentence(text.lower()),wait=False,username=inter.author.display_name,avatar_url=inter.author.display_avatar.url,allowed_mentions=discord.AllowedMentions.none())
2828
await inter.response.send_message("yes done",ephemeral=True)
2929
Log.info(f"Uwufied a message from {inter.author.name} in #{inter.channel.name}")
3030

3131
@uwu.sub_command("auto","Enable the auto uwufier")
32-
async def auto(self, inter: disnake.ApplicationCommandInteraction):
32+
async def auto(self, inter: discord.ApplicationContext):
3333
try:
3434
users = uwu_data["users"]
3535
if inter.author.id in users:
3636
users.remove(inter.author.id)
37-
await inter.response.send_message("**Disabled** auto uwufier for user " + inter.author.mention, allowed_mentions=disnake.AllowedMentions.none())
37+
await inter.response.send_message("**Disabled** auto uwufier for user " + inter.author.mention, allowed_mentions=discord.AllowedMentions.none())
3838
Log.info(f"Disabled the user uwufier for {inter.author.name}")
3939
else:
4040
users.append(inter.author.id)
41-
await inter.response.send_message("**Enabled** auto uwufier for user " + inter.author.mention, allowed_mentions=disnake.AllowedMentions.none())
41+
await inter.response.send_message("**Enabled** auto uwufier for user " + inter.author.mention, allowed_mentions=discord.AllowedMentions.none())
4242
Log.info(f"Enabled the user uwufier for {inter.author.name}")
4343
uwu_data["users"] = users
4444
except Exception as e:
4545
Log.error(f"Could not toggle uwufier for user {inter.author.name}: {e}")
4646

4747
@uwu.sub_command("channel","Enable the auto uwufier for the current channel")
48-
async def channel(self, inter: disnake.ApplicationCommandInteraction):
48+
async def channel(self, inter: discord.ApplicationContext):
4949
try:
5050
if inter.channel.id in uwu_data["channels"]:
5151
uwu_data["channels"].remove(inter.channel.id)
@@ -59,21 +59,21 @@ async def channel(self, inter: disnake.ApplicationCommandInteraction):
5959
Log.error(f"Could not toggle uwufier for channel #{inter.channel.name}: {e}")
6060

6161
@uwu.sub_command("ban","Ban a user from using the uwu features")
62-
async def ban(self, inter: disnake.ApplicationCommandInteraction, user: disnake.Member):
62+
async def ban(self, inter: discord.ApplicationContext, user: discord.Member):
6363
try:
6464
if user.id in uwu_data["banned"]:
6565
uwu_data["banned"].remove(user.id)
66-
await inter.response.send_message(f"**Unbanned** user {user.mention} from the uwufier.", allowed_mentions=disnake.AllowedMentions.none())
66+
await inter.response.send_message(f"**Unbanned** user {user.mention} from the uwufier.", allowed_mentions=discord.AllowedMentions.none())
6767
Log.info(f"Unbanned {user.name} from the uwufier.")
6868
else:
6969
uwu_data["banned"].append(user.id)
70-
await inter.response.send_message(f"**Banned** user {user.mention} from the uwufier.", allowed_mentions=disnake.AllowedMentions.none())
70+
await inter.response.send_message(f"**Banned** user {user.mention} from the uwufier.", allowed_mentions=discord.AllowedMentions.none())
7171
Log.info(f"Banned {user.name} from the uwufier.")
7272
except Exception as e:
7373
Log.error(f"Could not ban user {user.name} from the uwufier: {e}")
7474

7575
@uwu.sub_command("user","Enable the auto uwufier for another user")
76-
async def auto(self, inter: disnake.ApplicationCommandInteraction, user: disnake.Member):
76+
async def auto(self, inter: discord.ApplicationContext, user: discord.Member):
7777
try:
7878
users = uwu_data["users"]
7979
if user.id in users:
@@ -89,7 +89,7 @@ async def auto(self, inter: disnake.ApplicationCommandInteraction, user: disnake
8989
Log.error(f"Could not toggle uwufier for user {user.name}: {e}")
9090

9191
@uwu.sub_command("override","Toggle all uwu features")
92-
async def override(self, inter: disnake.ApplicationCommandInteraction):
92+
async def override(self, inter: discord.ApplicationContext):
9393
try:
9494
if uwu_data["enabled"]:
9595
uwu_data["enabled"] = False

0 commit comments

Comments
 (0)