Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Chatbot/niki2.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
157 lines (141 sloc)
4.96 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import math | |
import time | |
import requests | |
import json | |
from discord.ext.commands import Bot | |
from discord.ext import commands | |
from discord import Game | |
bot_prefix = ("?", "!", ".") | |
TOKEN = "NTA1MzY3NTU4OTU4ODc0NjM0.DrSj3g.g7nWCSmGMTEQtPlmrkA1JldsmvQ" | |
client = Bot(command_prefix=bot_prefix) | |
################## | |
#On ready command# | |
################## | |
@client.event | |
async def on_ready(): | |
await client.change_presence(game=Game(name="some gay stuff")) | |
print("Fam's ready to get gucci") | |
######################## | |
#Random answers command# | |
######################## | |
@client.command(name = 'Questions', | |
description = 'Answers basic question with random answers.', | |
brief = 'Answers lit questions.', | |
aliases = ['quest','q',], | |
pass_context = True) | |
async def eightball(context): | |
possible_responses = ['Yes', 'No', 'Maybe', "I'll think about it"] | |
await client.say(random.choice(possible_responses)+ " " + context.message.author.mention) | |
##################### | |
#Calculator Commands# | |
##################### | |
#Square Command | |
@client.command(name = 'sqr', | |
description = 'Squares your number.', | |
brief = 'Square function', | |
aliases = ['square','^']) | |
async def square(number): | |
squared_value = int(number) * int(number) | |
await client.say(str(number)+ " squared is " + str(squared_value)) | |
#Divide Command | |
@client.command(name = 'div', | |
description = 'Divides the first number by second one.', | |
brief = 'Dividing function', | |
aliases = ['/','divide']) | |
async def divide(number1,number2): | |
divided_value = int(number1)/int(number2) | |
await client.say('The answer is: ' + str(divided_value)) | |
#Plus Command | |
@client.command(name = 'plus', | |
description = 'Adds together both numbers.', | |
brief = 'Plus function', | |
aliases = ['+']) | |
async def plus(number1,number2): | |
plus_value = int(number1) + int(number2) | |
await client.say('The answer is: ' + str(plus_value)) | |
#Minus Command | |
@client.command(name = 'minus', | |
description = 'Minuses the second number from the first number.', | |
brief = 'Minus function', | |
aliases = ['-','min']) | |
async def minus(number1,number2): | |
minus_value = int(number1) - int(number2) | |
await client.say('The answer is: ' + str(minus_value)) | |
#Multiply Command | |
@client.command(name = 'multiply', | |
description = 'Multiplies first number by second one.', | |
brief = 'Multiply function', | |
aliases = ['*','multi']) | |
async def multiply(number1,number2): | |
multiply_value = int(number1) * int(number2) | |
await client.say('The answer is: ' + str(multiply_value)) | |
################### | |
#The clear command# | |
################### | |
@client.command(name = 'clear', | |
description = 'Clears the chat.', | |
brief = 'Clears the chat', | |
aliases = ['c', 'feetusdeletus'], | |
pass_context=True) | |
async def clear(ctx, amount = 100): | |
channel = ctx.message.channel | |
messages = [] | |
async for message in client.logs_from(channel, limit=int(amount) + 2): | |
messages.append(message) | |
await client.delete_messages(messages) | |
await client.say('Messages deleted fam') | |
######################### | |
#Time Command#In Working# | |
######################### | |
@client.command(name = 'time', | |
brief = 'Under construction.') | |
async def time(): | |
msg = "The time is currently " | |
await client.say(message.channel, msg + str(message.timestamp)) | |
################ | |
#logout command# | |
################ | |
@client.command(name = 'logout', | |
description = 'Logouts Chad.', | |
brief = 'Logouts Chad', | |
aliases = ['l','bye'], | |
pass_context = True) | |
async def logout(context): | |
possible_responses = ['See you later alligator',"Fam's out", "See you in a while"] | |
await client.say(random.choice(possible_responses)+ " " + context.message.author.mention) | |
await client.close() | |
############# | |
#Pin Command# | |
############# | |
@client.command(name = 'pin', | |
description = 'Pins your message.', | |
brief = 'Pins a message', | |
aliases = ['p'], | |
pass_context = True) | |
async def pin(context): | |
message = context.message | |
await client.pin_message(message) | |
await client.say('I pinned your message.') | |
############### | |
#UnPin Command# | |
############### | |
@client.command(name = 'unpin', | |
description = 'Unpins your messages', | |
brief = 'Unpins a message', | |
aliases = ['unp'], | |
pass_context = True) | |
async def unpin(context): | |
message = context.message | |
await client.unpin_message(message) | |
await client.say('I unpined your message.') | |
########## | |
#Pin List# | |
########## | |
@client.command(name = 'pinlist', | |
pass_context = True) | |
async def pinlist(context): | |
command = client.get_all_channels | |
await client.pins_from(command.channel) | |
await client.say('Your pinned messages.') | |
client.run(TOKEN) |