Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 39 additions & 47 deletions bot_utils/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import topgg
from pycord.ext import commands
from thefuzz import fuzz

from bot_utils.background_tasks import BackgroundTasks
from bot_utils.mongomethods import (
create_prefix,
Expand All @@ -17,6 +18,7 @@


class CountryBot(commands.Bot):

def __init__(self):
self.owner = 751594192739893298
self.description = "Check out our slash commands! Type `/` to bring up all of the slash commands! If you do not see any slash commands from country bot, then please kick country bot and use [this link to invite it again](https://discord.com/api/oauth2/authorize?client_id=810662403217948672&permissions=2048&scope=bot%20applications.commands)"
Expand All @@ -30,19 +32,20 @@ def __init__(self):
_ = SlashCommand(self, sync_commands=True)

self.topgg_webhook = topgg.WebhookManager(self).dbl_webhook(
"/dblwebhook", "dbl_password"
)
"/dblwebhook", "dbl_password")
self.topgg_webhook.run(4355)

menu = DefaultMenu("◀️", "▶️", "❌") # You can copy-paste any icons you want.
menu = DefaultMenu("◀️", "▶️",
"❌") # You can copy-paste any icons you want.
ending_note = "Type {help.clean_prefix}help command to get information on a command\nType {help.clean_prefix}help category to get information on a category\nPlease do not put text in <> or []\n<> = mandatory argument, [] = optional argument"
self.help_command = PrettyHelp(
navigation=menu, color=discord.Colour.red(), ending_note=ending_note
)
self.help_command = PrettyHelp(navigation=menu,
color=discord.Colour.red(),
ending_note=ending_note)
dbl_token = os.environ["TOPGGTOKEN"]
self.topggpy = topgg.DBLClient(
self, dbl_token, autopost=True, post_shard_count=True
)
self.topggpy = topgg.DBLClient(self,
dbl_token,
autopost=True,
post_shard_count=True)

self.tasks = BackgroundTasks(self)

Expand All @@ -60,24 +63,18 @@ def run(self):
self.run(os.getenv("TOKEN"))

async def on_message(self, msg):
if (
msg.content == f"<@810662403217948672> prefix"
or msg.content == f"<@!810662403217948672> prefix"
):
if (msg.content == f"<@810662403217948672> prefix"
or msg.content == f"<@!810662403217948672> prefix"):
prefix = self.bot.command_prefix(self.bot, msg)
await msg.channel.send(f"My prefix in this server is `{prefix}`")

elif (
msg.content == f"<@810662403217948672>prefix"
or msg.content == f"<@!810662403217948672>prefix"
):
elif (msg.content == f"<@810662403217948672>prefix"
or msg.content == f"<@!810662403217948672>prefix"):
prefix = self.bot.command_prefix(self.bot, msg)
await msg.channel.send(f"My prefix in this server is `{prefix}`")

elif (
msg.content == "<@810662403217948672>"
or msg.content == "<@!810662403217948672>"
):
elif (msg.content == "<@810662403217948672>"
or msg.content == "<@!810662403217948672>"):
prefix = self.bot.command_prefix(self.bot, msg)
await msg.channel.send(f"My prefix in this server is `{prefix}`")

Expand Down Expand Up @@ -106,17 +103,15 @@ async def on_dbl_vote(self, data):
"Thanks for voting! Unfortunately since you have not made a country, you can't redeem any rewards :( To create a country type `.start` Remember, replace `.` with the prefix of the bot in the server you are in!"
)
return
await update(
(
user.id,
a[0][0],
a[0][1] + (1000 * (a[0][5] + 1)),
a[0][2],
a[0][3],
a[0][4],
a[0][10],
)
)
await update((
user.id,
a[0][0],
a[0][1] + (1000 * (a[0][5] + 1)),
a[0][2],
a[0][3],
a[0][4],
a[0][10],
))
await update_coins((user.id, a[0][11] + (100 * a[0][5])))
await user.send(
"Thanks for voting, I appreciate it! Check your profile to see the received rewards!"
Expand Down Expand Up @@ -163,21 +158,18 @@ async def on_command_error(self, ctx, error):
pass
guild = self.bot.get_guild(821872779523522580)
channel = discord.utils.get(guild.channels, name="bug-logs")
await channel.send(
embed=discord.Embed(
title="Error in executing a command",
description=f"New error when executing command: {ctx.command.name}\n**Error**: {error}",
)
)

elif isinstance(error, discord.ext.commands.errors.MissingRequiredArgument):
await ctx.send(
embed=discord.Embed(
title="Incorrect Usage",
description=f"Correct Usage: ```{ctx.prefix}{ctx.command.name} {ctx.command.signature}```",
color=discord.Colour.red(),
)
)
await channel.send(embed=discord.Embed(
title="Error in executing a command",
description=f"New error when executing command: {ctx.command.name}\n**Error**: {error}",
))

elif isinstance(error,
discord.ext.commands.errors.MissingRequiredArgument):
await ctx.send(embed=discord.Embed(
title="Incorrect Usage",
description=f"Correct Usage: ```{ctx.prefix}{ctx.command.name} {ctx.command.signature}```",
color=discord.Colour.red(),
))

elif isinstance(error, discord.ext.commands.errors.MemberNotFound):
embed = discord.Embed(title="Hmm", description=error.args[0])
Expand Down
59 changes: 26 additions & 33 deletions slash_commands/admin_commands/adminstuff.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,65 +8,58 @@


class AdminCommands(
commands.Cog,
name="Admin/Configuration (slash)",
description="Commands only for admins",
commands.Cog,
name="Admin/Configuration (slash)",
description="Commands only for admins",
):

def __init__(self, bot):
self.bot = bot

@cog_ext.cog_slash(description="Set up a channel to receive updates about the bot")
@cog_ext.cog_slash(
description="Set up a channel to receive updates about the bot")
@commands.has_permissions(administrator=True)
async def configurechannel(self, ctx, channel: discord.TextChannel):

try:
await create_update(channel.id)
except:
await ctx.send(
embed=discord.Embed(
title="Hey!",
description="This channel has already been configured!",
)
)
await ctx.send(embed=discord.Embed(
title="Hey!",
description="This channel has already been configured!",
))
return

try:
await channel.send(
embed=discord.Embed(
title="Success",
description="Channel is configured to receive updates about the bot!",
)
)
await channel.send(embed=discord.Embed(
title="Success",
description="Channel is configured to receive updates about the bot!",
))
await ctx.send(f"Great! {channel} is now configured!")
except:
await ctx.send(
embed=discord.Embed(
title="Oh No!",
description=":x: I couldn't send mesages in that channel. Please provide a valid channel! Or make sure that I have permission to talk there!",
)
)
await ctx.send(embed=discord.Embed(
title="Oh No!",
description=":x: I couldn't send mesages in that channel. Please provide a valid channel! Or make sure that I have permission to talk there!",
))
await delete_update(channel.id)
return

@cog_ext.cog_slash(description="Make a channel not receive updates about the bot")
@cog_ext.cog_slash(
description="Make a channel not receive updates about the bot")
@commands.has_permissions(administrator=True)
async def unconfigurechannel(self, ctx, channel: discord.TextChannel):
try:
await delete_update(int(channel.id))

except:
await ctx.send(
embed=discord.Embed(
title="Oh No!", description=":x: Please provide a valid channel!"
)
)
await ctx.send(embed=discord.Embed(
title="Oh No!",
description=":x: Please provide a valid channel!"))
return

await ctx.send(
embed=discord.Embed(
title="Success", description=f"{channel} won't receive update messages"
)
)
await ctx.send(embed=discord.Embed(
title="Success",
description=f"{channel} won't receive update messages"))


def setup(bot):
Expand Down