Updating/Adding Commentary

Added ~marry command
Added a ~remindme command
pull/2/head
sgoudham 4 years ago
parent 237bacbc2b
commit 00375ec7f5

@ -36,24 +36,13 @@ async def on_ready():
# Bot ~Ping command in milliseconds # Bot ~Ping command in milliseconds
@client.command(aliases=["Ping"]) @client.command(aliases=["Ping"])
@commands.has_any_role('Hamothy', 'Servant') @commands.is_owner()
async def ping(ctx): async def ping(ctx):
# Send the latency of the bot (ms) # Send the latency of the bot (ms)
await ctx.send(f'Pong! {round(client.latency * 1000)}ms') await ctx.send(f'Pong! {round(client.latency * 1000)}ms')
@client.event # Bot Event for handling cooldown error/permission errors
async def on_message(message):
channel = client.get_channel(721449922838134876)
if message.channel == message.author.dm_channel:
if message.author.id == 154840866496839680:
await channel.send(message.content)
else:
return
await client.process_commands(message)
# Bot Event for handling cooldown error
@client.event @client.event
async def on_command_error(ctx, error): async def on_command_error(ctx, error):
if isinstance(error, commands.CommandOnCooldown): if isinstance(error, commands.CommandOnCooldown):
@ -65,13 +54,10 @@ async def on_command_error(ctx, error):
# Delete the message # Delete the message
await message.delete() await message.delete()
# Bot Event for handling permission errors
# Bot Event for handling missing argument error if isinstance(error, commands.CheckFailure):
@client.event # Send an error message to the user saying that they don't have permission to use this command
async def on_command_error(ctx, target: discord.member): message = await ctx.send("Uh oh! You don't have permission to use this command!")
if isinstance(target, commands.MissingRequiredArgument):
# Send an error message to the user saying that an argument is missing
message = await ctx.send("Uh oh! Couldn't find anyone to mention! Try again!")
# Let the user read the message for 1.5 seconds # Let the user read the message for 1.5 seconds
await asyncio.sleep(1.5) await asyncio.sleep(1.5)
@ -79,12 +65,12 @@ async def on_command_error(ctx, target: discord.member):
await message.delete() await message.delete()
# Bot Event for handling permission errors # Bot Event for handling missing argument error
@client.event @client.event
async def on_command_error(ctx, error): async def on_command_error(ctx, target: discord.member):
if isinstance(error, commands.CheckFailure): if isinstance(target, commands.MissingRequiredArgument):
# Send an error message to the user saying that they don't have persmission to use this command # Send an error message to the user saying that an argument is missing
message = await ctx.send("Uh oh! You don't have permission to use this command!") message = await ctx.send("Uh oh! Couldn't find anyone to mention! Try again!")
# Let the user read the message for 1.5 seconds # Let the user read the message for 1.5 seconds
await asyncio.sleep(1.5) await asyncio.sleep(1.5)
@ -259,29 +245,80 @@ async def on_raw_reaction_remove(payload):
print(ex) print(ex)
# ~marry command allows the bot to wed two young lovers together
@client.command() @client.command()
async def marry(ctx, member: discord.Member): async def marry(ctx, member: discord.Member):
await ctx.send(f"{ctx.author.mention} **proposes to** {member.mention} **Do you accept??** " # Send a message to the channel mentioning the author and the person they want to wed.
f"\nRespond with [y(es)/n(o)]") await ctx.send(f"{ctx.author.mention} **Proposes To** {member.mention} **Do you accept??** "
f"\nRespond with [yes/no]")
# A check that makes sure that the reply is not from the author
# and that the reply is in the same channel as the proposal
def check(m): def check(m):
return m.author == member return m.author == member and m.channel == ctx.channel
# Surround with try/except to catch any exceptions that may occur
try: try:
# Wait for the message from the mentioned user
msg = await client.wait_for('message', check=check, timeout=10) msg = await client.wait_for('message', check=check, timeout=10)
if msg.content.lower() in ['y', 'yes']: # if the person says yes
await ctx.send(f"Congratulations! {ctx.author.mention} and {member.mention} are now married to each other!") if msg.content.lower() in ['y', 'yes', 'yea']:
elif msg.content.lower() in ['n', 'no']: # Congratulate them!
await ctx.send(f"Unlucky, maybe another time! {ctx.author.mention}") await ctx.send(
f"Congratulations! ヽ(・∀・)ノ {ctx.author.mention} and {member.mention} are now married to each other!")
# if the person says no
elif msg.content.lower() in ['n', 'no', 'nah']:
# Try to console the person and wish them the best in their life
await ctx.send(f"Unlucky (T▽T), maybe another time! {ctx.author.mention}")
else: else:
await ctx.send("I did not understand that, aborting!") # Abort the process as the message sent did not make sense
await ctx.send("Senpaiiii! Speak English Please ⋋_⋌")
except asyncio.TimeoutError as e: except asyncio.TimeoutError as e:
print(e) print(e)
await ctx.send("Looks like you waited too long.") # Send out an error message if the user waited too long
await ctx.send("Awww they waited too long (✖╭╮✖)")
# Allows the bot to echo the dm's that it receives
@client.event
async def on_message(message):
# Get the channel id of the channel it wants to push messages to
channel = client.get_channel(721449922838134876)
# Run the bot, allowing to come online # If the channel that the message is sent in is private
if message.channel == discord.ChannelType.private:
# if the message author id is equal to mine
if message.author.id == 578919370697342977:
# Echo the message contents to the channel specified
await channel.send(message.content)
else:
# Do nothing
return
await client.process_commands(message)
# ~remindme command to allow the bot to dm you to remind you of something
@client.command()
async def remindme(ctx, time=None, *, text):
# Grab the author and store it in "author"
author = ctx.message.author
# If a value for time as been given
if time:
# Sleep the thread for the amount of time specified by the user
await asyncio.sleep(float(time))
# Send message to user's dms
await author.send(text)
# else no time has been given
else:
# Instantly Send message to user's dms
await author.send(text)
# Run the bot, allowing it to come online
try: try:
client.run(API_TOKEN) client.run(API_TOKEN)
except discord.errors.LoginFailure as e: except discord.errors.LoginFailure as e:
@ -386,14 +423,4 @@ async def marry(ctx, target: discord.Member):
await ctx.send('bar') await ctx.send('bar')
bar = await client.wait_for('message', check=check) bar = await client.wait_for('message', check=check)
@client.command()
async def dm2(ctx, time=None, *, text):
author = ctx.get_user_info(154840866496839680)
if time:
await asyncio.sleep(float(time))
await author.send(text)
else:
await author.send(text)
""" """

Loading…
Cancel
Save