VideoCarp

CarpBot

Jul 19th, 2020
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.47 KB | None | 0 0
  1. from discord.ext import commands
  2. import discord
  3.  
  4. _cd = commands.CooldownMapping.from_cooldown(1.0, 60.0, commands.BucketType.member)
  5.  
  6. #Bot command prefix, I set to c? for now, I'll change if they want me to.
  7. bot = commands.Bot(command_prefix='c?')
  8. bot.remove_command("help")
  9. authorid = user.id
  10. #Above allows for the things to work, and removes the already existing default help command, to be custom.
  11. @bot.event
  12. async def on_ready():
  13.     print("Logged in as {0.user}".format(bot))
  14.  
  15. @bot.event
  16. async def on_message(message):
  17.     if message.author == bot.user:
  18.         return
  19.     await bot.process_commands(message)
  20.  
  21.     if message.content.startswith("c?hello"):
  22.         await message.channel.send("Hello!")
  23. #Above are a few of "trigger test commands", these are not commands, however are executed if a message starts with the content
  24. #specified.
  25. #Please do notice that I will be coding mostly private bots.
  26.  
  27. # Syntax for command. (For myself)
  28. #@bot.command()
  29. #async def commandname(ctx, arg):
  30. #    await ctx.send(arg)
  31. @bot.command()
  32. async def ping(ctx):
  33.     await ctx.send("Pong! Bot latency is {0}".format(round(bot.latency, 1)))
  34. #Above is the ping check command, this also specifies the latency.
  35.    
  36. @bot.command()
  37. async def easteregg(ctx):
  38.     await ctx.send("You have discovered a bot easter egg!")
  39. #Below is the say command, which repeats the user's arguments, in this case, quotes will NOT be required for more than 1 word.
  40. #The setmodmail command currently does NOT work, these commands are IN PROGRESS, and may possibly be cancelled due to the fact
  41. #they may be useless.
  42. @bot.command()
  43. async def say(ctx, *, message: str):
  44.     await ctx.send(message)  
  45. @bot.command()
  46. async def help(ctx):
  47.     await ctx.author.send("Thanks for using this bot, a list of available commands are: \
  48.    `ping, say, help, apply, submit, modmail`. \
  49.    Help Command: This! \
  50.    Say Command: Makes the bot say things. \
  51.    Ping Command: Checks and gives you the bot latency.\
  52.    Apply: Shows you the application.\
  53.    Submit: Submit your application.\
  54.    ")
  55. # The backslash creates a new line, making it easier for me to write it in a great format. This directly messages the person who
  56. #executed the command.
  57. @bot.command()
  58. async def apply(ctx):
  59.     await message.author.send("This server's set application is: TEXT.\
  60.    Submit by running `submit <application>`.)
  61. #The application above is not customizable through commands, I'll be mostly creating private bots, and upon request, I will set
  62. #up their applications the way they want, although this bot is just an example. I'll also be hired for VERY cheap, and they'll
  63. #the code, however I will not host the bot for them, rather give them the code they need and tell/show them how to host it.
  64. #I will add a command that allows them to change the application, rather than having to tweak the code if requested. Enough of
  65. #that, here's the submit command.
  66. @bot.command()
  67. async def submit(ctx, *, appsubmit: str):
  68.    channel = client.get_channel("Channel's id. I'll replace it for them, read comments though")
  69.    await channel.send('Application received from <@' + authorid '>:'\
  70.                      + appsubmit)
  71. #I use bot.run rather than client.run, because I use bot rather than client. The login is still successful.
  72. #The app submit looks pretty weird, this will mention the submitter, which gives their permanent ID and username may show.
  73. #I do know authorid is not valid, however if you look, there's a variable.
  74. bot.run('bottoken')
Add Comment
Please, Sign In to add comment