First commit

This commit is contained in:
Sid 2021-12-18 17:55:54 +01:00 committed by GitHub
parent f729f5df66
commit 125792eb08
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 69 additions and 0 deletions

19
commands.md Normal file
View file

@ -0,0 +1,19 @@
## List of sidBots features/commands:
--------------------------------
>**!help**
> List of commands
>**!hello**
> Bot responds with "Hello!"
>**!ping**
> Bot responds with "Pong!" and botlatency
>**!github**
> Flexes github link
>**!coinflip**
> Heads or Tails!
>**merry christmas**
> Someone writes "merry christmas" and bot responds w/ legendary vine quote selected from an array

50
main.py Normal file
View file

@ -0,0 +1,50 @@
import os
import discord
import random
client = discord.Client()
my_secret = os.environ['TOKEN']
xmasAnswers = ['Happy Chrismis!', 'Its Chrismin!', 'Merry Chrisis!', 'Merry Chrysler!']
coinflip = ['Heads', 'Not Sonic lol (Tails..)']
# when bot is ready
@client.event # Register an event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
# bot sense a message & responds
@client.event
async def on_message(message):
# if message is from bot, return nothing
if message.author == client.user:
return
# user sends "!hello", bot responds w/ "Hello!"
if message.content.lower().startswith('!hello'):
await message.channel.send('Hello!')
# user sends "!ping", bot responds w/ "Pong" + bot latency
elif message.content.lower().startswith('!ping'):
await message.channel.send(f'Pong :ping_pong: (Bot latency: **{round(client.latency * 1000)}ms**)')
# user sends "!help", bot sends commands file
elif message.content.lower().startswith("!help"):
await message.channel.send(file=discord.File("commands.md"))
# user sends "!coinflip", bot sends commands file
elif message.content.lower().startswith("!coinflip"):
await message.channel.send(random.choice(coinflip))
# user sends "!github", bot sends commands file
elif message.content.lower().startswith("!github"):
await message.channel.send('https://github.com/SindreKjelsrud')
# someone writes "merry christmas", bot responds w/ legendary vine quote
elif "merry christmas" in message.content.lower():
await message.channel.send(random.choice(xmasAnswers) + ':santa:')
# run bot
client.run(my_secret)