Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import discord
- from discord.ext import commands
- import asyncio
- import random
- import time
- Client = discord.Client()
- client = commands.Bot(command_prefix = '!')
- client.remove_command('help')
- IGNORED = (commands.CommandOnCooldown, commands.CommandNotFound)
- TOKEN = ""
- OWNER = ""
- COOLDOWN = 3
- #https://discordapp.com/oauth2/authorize?&client_id=YOURCLIENTHERE&scope=bot&permissions=YOURPERMSHERE
- @client.event
- async def on_ready():
- print("Bot is online")
- await client.change_presence(game=discord.Game(name=''))
- @client.event
- async def on_resumed():
- print("Bot has reconnected")
- @client.event
- async def on_command_error(err, ctx):
- if isinstance(err, IGNORED):
- return
- elif isinstance(err, TypeError):
- await client.send_message(ctx.message.channel, "What? I don't understand how to do this")
- else:
- await client.send_message(ctx.message.channel, "Uhmmmm, something went wrong there...")
- print("Command: " + ctx.message.content + "\nError: ")
- print(err)
- ##########################################################
- @client.event
- async def on_message(message):
- if message.content.lower == "horse":
- await client.send_message(message.channel, "pussy")
- await client.process_commands(message)
- @client.command()
- @commands.cooldown(1, COOLDOWN, commands.BucketType.user)
- async def bon():
- await client.say("bon")
- @client.command(pass_context=True)
- async def rest(ctx):
- if ctx.message.author.id == OWNER:
- await client.say("Goodnight!")
- id = ctx.message.server.id
- await client.close()
- print('Bot is offline')
- else:
- await client.say("You're not the boss of me!")
- ##########################################################
- def run_client(client, *args, **kwargs):
- loop = asyncio.get_event_loop()
- while True:
- try:
- loop.run_until_complete(client.start(*args, **kwargs))
- except Exception as e:
- print("Error", e)
- print("Waiting until restart")
- time.sleep(600)
- if __name__ == "__main__":
- run_client(client, TOKEN)
- input("Bot ended")
- quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement