Skip to content

Commit 9f3709a

Browse files
committed
Migrated from discord.py to nextcord
1 parent f3a006b commit 9f3709a

File tree

10 files changed

+77
-78
lines changed

10 files changed

+77
-78
lines changed

modules/admin.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
Contains commands relating to administrator tasks.
33
"""
44

5-
import black
6-
import discord.ext.commands as commands
7-
import discord.ui as UI
5+
import nextcord.ext.commands as commands
6+
import nextcord.ui as UI
7+
import nextcord
88
import helpers
99
import asyncio
1010
import discord
@@ -31,13 +31,13 @@ async def clear(ctx: commands.Context, amount: int | None):
3131
The number of messages to clear.
3232
"""
3333
if amount is not None: # If the user selected an amount, clear that amount of messages
34-
await ctx.send(embed=discord.Embed(title=f'🛠️ Deleting **{amount}** messages.'))
34+
await ctx.send(embed=nextcord.Embed(title=f'🛠️ Deleting **{amount}** messages.'))
3535
return await ctx.channel.purge(limit=amount)
3636

3737
# Else, create two buttons
3838
# Then ask the user if they would like to clear all messages in the channel
39-
yes_button = UI.Button(label='Yes', style=discord.ButtonStyle.green)
40-
no_button = UI.Button(label='No', style=discord.ButtonStyle.red)
39+
yes_button = UI.Button(label='Yes', style=nextcord.ButtonStyle.green)
40+
no_button = UI.Button(label='No', style=nextcord.ButtonStyle.red)
4141

4242
yes_button.callback = lambda interaction: \
4343
(await interaction.channel.purge(limit=None) for _ in '_').__anext__()
@@ -58,7 +58,7 @@ async def clear(ctx: commands.Context, amount: int | None):
5858
@commands.command()
5959
@commands.has_permissions(kick_members=True)
6060
@commands.cooldown(1, 30, commands.BucketType.user)
61-
async def kick(ctx: commands.Context, member: discord.Member, *, reason=None):
61+
async def kick(ctx: commands.Context, member: nextcord.Member, *, reason=None):
6262
"""
6363
Kicks a specified member from a server.
6464
@@ -80,7 +80,7 @@ async def kick(ctx: commands.Context, member: discord.Member, *, reason=None):
8080
@commands.command()
8181
@commands.has_permissions(ban_members=True)
8282
@commands.cooldown(1, 30, commands.BucketType.user)
83-
async def ban(ctx: commands.Context, member: discord.Member, *, reason=None):
83+
async def ban(ctx: commands.Context, member: nextcord.Member, *, reason=None):
8484
"""
8585
Bans a specified member from a server.
8686
@@ -102,7 +102,7 @@ async def ban(ctx: commands.Context, member: discord.Member, *, reason=None):
102102
@commands.command()
103103
@commands.has_permissions(ban_members=True)
104104
@commands.cooldown(1, 30, commands.BucketType.user)
105-
async def softban(ctx: commands.Context, member: discord.Member, days=1, reason=None):
105+
async def softban(ctx: commands.Context, member: nextcord.Member, days=1, reason=None):
106106
"""
107107
Temporarily bans a specified member from a server.
108108
@@ -128,7 +128,7 @@ async def softban(ctx: commands.Context, member: discord.Member, days=1, reason=
128128
@commands.command()
129129
@commands.has_permissions(ban_members=True)
130130
@commands.cooldown(1, 2, commands.BucketType.user)
131-
async def unban(ctx: commands.Context, user: discord.User):
131+
async def unban(ctx: commands.Context, user: nextcord.User):
132132
"""
133133
Unbans a specified user from a server.
134134
@@ -205,10 +205,10 @@ async def clearblacklist(ctx: commands.Context):
205205
if id not in blacklist.keys():
206206
return await ctx.send(f':x: {mention}: This server does not have any words blacklisted.')
207207

208-
yes_button = UI.Button(label='Yes', style=discord.ButtonStyle.green, emoji='👍🏻')
209-
no_button = UI.Button(label='No', style=discord.ButtonStyle.red, emoji='👎🏻')
208+
yes_button = UI.Button(label='Yes', style=nextcord.ButtonStyle.green, emoji='👍🏻')
209+
no_button = UI.Button(label='No', style=nextcord.ButtonStyle.red, emoji='👎🏻')
210210

211-
async def yes(interaction: discord.Interaction):
211+
async def yes(interaction: nextcord.Interaction):
212212
for server_id in blacklist.keys():
213213
if server_id == id:
214214
del blacklist[server_id]
@@ -221,7 +221,7 @@ async def yes(interaction: discord.Interaction):
221221

222222
yes_button.callback = yes
223223

224-
async def no(interaction: discord.Interaction):
224+
async def no(interaction: nextcord.Interaction):
225225
return await interaction.message.channel.send(f':thumbsup: {mention}: Ok!')
226226

227227
no_button.callback = no

modules/errors.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
error handlers.
66
"""
77

8-
import discord.ext.commands as commands
9-
import discord.ui as UI
8+
import nextcord.ext.commands as commands
9+
import nextcord.ui as UI
1010
import helpers
11-
import discord
11+
import nextcord
1212
import traceback
1313
import math
1414
import sys
@@ -63,7 +63,7 @@ async def on_command_error(ctx: commands.Context, error):
6363
try:
6464
message += 'You can\'t use this command in private messages.'
6565

66-
except discord.Forbidden:
66+
except nextcord.Forbidden:
6767
return
6868

6969
case _:
@@ -72,7 +72,7 @@ async def on_command_error(ctx: commands.Context, error):
7272

7373
return
7474

75-
button_continue = UI.Button(label='OK', style=discord.ButtonStyle.green)
75+
button_continue = UI.Button(label='OK', style=nextcord.ButtonStyle.green)
7676
button_docspage = UI.Button(label='Help',
7777
url='https://github.com/matthewflegg/beepboop/blob/main/README.md',
7878
)

modules/events.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
Contains all of the events that the client will listen to.
33
"""
44

5-
import discord.ext.commands as commands
5+
import nextcord.ext.commands as commands
66
import helpers
7-
import discord
7+
import nextcord
88
import start
99
import json
1010

@@ -20,7 +20,7 @@ def __init__(self, client: commands.Bot) -> None:
2020
self.client = client
2121

2222
@commands.Cog.listener()
23-
async def on_member_join(self, member: discord.Member):
23+
async def on_member_join(self, member: nextcord.Member):
2424
"""
2525
Sends a welcome message when a member joins a server.
2626
@@ -33,7 +33,7 @@ async def on_member_join(self, member: discord.Member):
3333
await helpers.send_message(member, "Welcome")
3434

3535
@commands.Cog.listener()
36-
async def on_member_remove(self, member: discord.Member):
36+
async def on_member_remove(self, member: nextcord.Member):
3737
"""
3838
Sends a welcome message when a member leaves a server.
3939
@@ -46,7 +46,7 @@ async def on_member_remove(self, member: discord.Member):
4646
await helpers.send_message(member, "Goodbye")
4747

4848
@commands.Cog.listener()
49-
async def on_message(self, message: discord.Message):
49+
async def on_message(self, message: nextcord.Message):
5050
"""
5151
Called when a message is sent.
5252
@@ -73,7 +73,7 @@ async def on_message(self, message: discord.Message):
7373
await message.delete()
7474

7575
@commands.Cog.listener()
76-
async def on_reaction_add(self, reaction: discord.Reaction, user: discord.User):
76+
async def on_reaction_add(self, reaction: nextcord.Reaction, user: nextcord.User):
7777
"""
7878
Prevents users from voting more than once on a poll.
7979
@@ -90,7 +90,7 @@ async def on_reaction_add(self, reaction: discord.Reaction, user: discord.User):
9090
The user that reacted to the poll.
9191
"""
9292
user = reaction.message.author
93-
cached = discord.utils.get(self.client.cached_messages, id=reaction.message.id)
93+
cached = nextcord.utils.get(self.client.cached_messages, id=reaction.message.id)
9494

9595
if user.id == self.client.user.id:
9696
return

modules/help.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
Contains the help command.
33
"""
44

5-
import discord.ext.commands as commands
6-
import discord
5+
import nextcord.ext.commands as commands
6+
import nextcord
77
import start
88

99

@@ -21,7 +21,7 @@ async def help(ctx: commands.Context):
2121
ctx: (Context)
2222
Command invocation context.
2323
"""
24-
embed = discord.Embed(
24+
embed = nextcord.Embed(
2525
title="Beep Boop Bot Documentation",
2626
color=start.colour,
2727
url="https://github.com/matthewflegg/beepboop/blob/main/README.md",

modules/helpers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
Contains utility functions to assist command modules.
33
"""
44

5-
import discord.ext.commands as commands
6-
import discord
5+
import nextcord.ext.commands as commands
6+
import nextcord
77

88

99
# |-------- UTILITY FUNCTIONS --------|
@@ -27,7 +27,7 @@ def add_commands(client: commands.Bot, *cmds):
2727

2828

2929
async def sanction(
30-
ctx: commands.Context, punishment: str, member: discord.Member, reason=None
30+
ctx: commands.Context, punishment: str, member: nextcord.Member, reason=None
3131
):
3232
"""
3333
Utility function that bans or kicks a member.
@@ -68,7 +68,7 @@ async def sanction(
6868
await member.send(message_member)
6969

7070

71-
async def lift_ban(ctx: commands.Context, ban_type: str, user: discord.User):
71+
async def lift_ban(ctx: commands.Context, ban_type: str, user: nextcord.User):
7272
"""
7373
Utility function that unbans a member.
7474

modules/misc.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
Contains miscellaneous commands to be used for fun.
33
"""
44

5-
import discord.ext.commands as commands
5+
import nextcord.ext.commands as commands
66
import helpers
77
import random
8-
import discord
8+
import nextcord
99
import json
1010
import start
1111
import requests
@@ -45,7 +45,7 @@ async def meme(ctx: commands.Context):
4545
content = requests.get('https://meme-api.herokuapp.com/gimme').text
4646
data = json.loads(content, )
4747

48-
meme = discord.Embed(
48+
meme = nextcord.Embed(
4949
title=str(data["title"]),
5050
color=start.colour
5151
)
@@ -65,7 +65,7 @@ async def poll(ctx: commands.Context, *poll: str):
6565
ctx (Context):
6666
Command invocation context.
6767
"""
68-
embed = discord.Embed(
68+
embed = nextcord.Embed(
6969
title=f'Poll by **{ctx.author.name}**:',
7070
color=start.colour,
7171
description=' '.join(poll)

0 commit comments

Comments
 (0)