Skip to content
This repository has been archived by the owner on Nov 14, 2022. It is now read-only.

Commit

Permalink
Merge pull request #5 from ItsZabbs/patch-1
Browse files Browse the repository at this point in the history
Updated the convert command
  • Loading branch information
Wamy-Dev authored Aug 7, 2022
2 parents 6ee98d7 + d9793c2 commit dd40a08
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ async def index():
intents.members = True
client = commands.Bot(command_prefix = '$', intents=intents)
client.remove_command('help')
#Putting all repeated lines in a function
def convert_command_embeds(link:str,author:discord.User):
embed = discord.Embed(title = "Here is your converted link!", colour = discord.Colour.from_rgb(4,132,188))
embed.set_author(name = author, icon_url = author.avatar.url)
embed.add_field(name = 'πŸ”—', value="https://"+link if not link.startswith("https://") else link, inline = False)
embed.set_footer(text = "If you like this project please donate using $donate in the server.")
sendembed = discord.Embed(title = "Please check your DMs!", colour = discord.Colour.from_rgb(4,132,188))
sendembed.set_author(name = author, icon_url = author.avatar.url)
sendembed.set_footer(text = "If you like this project please donate using $donate in the server.")
return embed,sendembed

@client.event
async def on_ready():
print(f'Bot is ready. Logged in as {client.user}(ID: {client.user.id}) ')
Expand All @@ -64,14 +75,8 @@ def check(msg):
link = base64.b64decode(beforecontent).decode('utf-8')
except:
await ctx.send('```❌ Invalid base64 link. Please try again.```')
embed = discord.Embed(title = "Here is your converted link!", colour = discord.Colour.from_rgb(4,132,188))
embed.set_author(name = ctx.message.author, icon_url = ctx.author.avatar.url)
embed.add_field(name = 'πŸ”—', value=f'https://{link}', inline = False)
embed.set_footer(text = "If you like this project please donate using $donate in the server.")
await ctx.author.send(embed = embed)
sendembed = discord.Embed(title = "Please check your DMs!", colour = discord.Colour.from_rgb(4,132,188))
sendembed.set_author(name = ctx.message.author, icon_url = ctx.author.avatar.url)
sendembed.set_footer(text = "If you like this project please donate using $donate in the server.")
embed,sendembed = convert_command_embeds(link,ctx.message.author)
await ctx.author.send(embed = embed)
await ctx.send(embed = sendembed)
else:
embed = discord.Embed(title = "Please respond with your base64 link.", colour = discord.Colour.from_rgb(251,172,4))
Expand All @@ -85,14 +90,8 @@ def check(msg):
link = base64.b64decode(beforecontent).decode('utf-8')
except:
await ctx.send('```❌ Invalid base64 link. Please try again.```')
embed = discord.Embed(title = "Here is your converted link!", colour = discord.Colour.from_rgb(4,132,188))
embed.set_author(name = ctx.message.author, icon_url = ctx.author.avatar.url)
embed.add_field(name = 'πŸ”—', value=f'https://{link}', inline = False)
embed.set_footer(text = "If you like this project please donate using $donate in the server.")
embed,sendembed = convert_command_embeds(link,ctx.message.author)
await ctx.author.send(embed = embed)
sendembed = discord.Embed(title = "Please check your DMs!", colour = discord.Colour.from_rgb(4,132,188))
sendembed.set_author(name = ctx.message.author, icon_url = ctx.author.avatar.url)
sendembed.set_footer(text = "If you like this project please donate using $donate in the server.")
await ctx.send(embed = sendembed)
except asyncio.TimeoutError:
await ctx.send('```❌ Timed out.```')
Expand Down

0 comments on commit dd40a08

Please sign in to comment.