Skip to content
Permalink
8bc302e830
Switch branches/tags

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?
Go to file
 
 
Cannot retrieve contributors at this time
184 lines (156 sloc) 8.71 KB
#imports
import asyncio
from discord import Game
from discord.ext import commands
import discord
import youtube_dl
import random
import requests
from lxml import html
from discord.utils import get
BOT_PREFIX = ("?")
# token would be where you put your bot's token to join as the client but it's going on github so nah
TOKEN = ""
client = commands.Bot(command_prefix=BOT_PREFIX)
extensions=["Fun","Music"]
async def start(self):
"""loads the opus libraries so that it can output audio on voice channels"""
discord.opus.load_opus(self.opus_library)
# ahmed's
@client.command(name="guesscountry",
description="has a list of all countries that have been web scrapped",
brief="randomly says a country",
pass_context=True)
async def guess_country(ctx):
page = requests.get('https://en.wikipedia.org/wiki/List_of_countries_by_intentional_homicide_rate')
tree = html.fromstring(page.content)
guesscountry = tree.xpath('//*[@id="mw-content-text"]/div/table[2]/tbody/tr/td[2]/table/tbody/tr/td[1]/a/text()')
await client.say("{0} {1}".format(ctx.message.author.mention, random.choice(guesscountry)))
# seva's
@client.command(description="takes a random joke from a list",
brief="says a random joke",
pass_context=True)
async def joke(ctx):
"""gives a random joke from the list below"""
jokes = ["Two men walk into a bar. The third one ducks!",
"Why was 6 afraid of 7? Because 7 ate 9!",
"I’m reading an antigravity book It’s impossible to put down!",
"What kind of cheese doesn’t belong to you? Nacho cheese!",
"You can’t trust atoms. They make up everything!",
"Why do mushrooms get invited to all the best parties? Because they are such fungis!"]
await client.say("{0} {1}".format(ctx.message.author.mention, random.choice(jokes)))
# ahmed's
@client.command(description="takes a random fact from a list",
brief="says a random fact",
pass_context=True)
async def facts(ctx):
"""gives a random fact from the list below"""
facts = ["Banging your head against a wall for one hour burns 150 calories.",
"In Switzerland it is illegal to own just one guinea pig.",
"Pteronophobia is the fear of being tickled by feathers.",
"Snakes can help predict earthquakes.",
"A flock of crows is known as a murder.",
"The oldest 'your mom' joke was discovered on a 3,500 year old Babylonian tablet.",
"So far, two diseases have successfully been eradicated: smallpox and rinderpest.",
"Cherophobia is an irrational fear of fun or happiness.",
"7% of American adults believe that chocolate milk comes from brown cows.",
"If you lift a kangaroo's tail off the ground it can't hop.",
"Bananas are curved because they grow towards the sun.",
"Billy goats urinate on their own heads to smell more attractive to females.",
"The inventor of the Frisbee was cremated and made into a Frisbee after he died.",
"During your lifetime, you will produce enough saliva to fill two swimming pools.",
"If Pinocchio says 'My Nose Will Grow Now', it would cause a paradox.",
"Polar bears could eat as many as 86 penguins in a single sitting...",
"Movie trailers were originally shown after the movie, which is why they were called 'trailers'.",
"An eagle can kill a young deer and fly away with it.",
"Heart attacks are more likely to happen on a Monday.",
"Tennis players are not allowed to swear when they are playing in Wimbledon.",
"In 2017 more people were killed from injuries caused by taking a selfie than by shark attacks.",
"The top six foods that make your fart are beans, corn, bell peppers, cauliflower, cabbage and milk.",
"There is a species of spider called the Hobo Spider.",
"A lion’s roar can be heard from 5 miles away.",
"Saint Lucia is the only country in the world named after a woman.",
"A baby spider is called a spiderling.",
"The United States Navy has started using Xbox controllers for their periscopes.",
"A baby octopus is about the size of a flea when it is born.",
"Scarecrows have been around longer than you might think – the first scarecrows known to history were made about three-thousand-years ago!.",
"The scientific name for brain freeze is sphenopalatine ganglioneuralgia."
"A New Jersey man flunked out of law school and subsequently sued the school for having accepted him in the first place.",
"Toni Morrison was the first African-American woman to receive a Nobel Prize. It was in recognition of her contributions to literature and poetry.",
"Laughing boosts the immune system, burns calories and reduces stress hormones, making it a very healthy activity.",
"Honey is a better cough suppressant than over-the-counter cough suppressants.",
"People are more likely to agree with a statement written in Baskerville than any other font.",
"3 out of 4 Americans use an emoji in text messaging every single day.",
"Due to a genetic defect, cats can’t taste sweet things.",
"According to the Centre for Retail Research, cheese is the most commonly shoplifted food in the world."
]
await client.say("{0} {1}".format(ctx.message.author.mention, random.choice(facts)))
# andrew's
@client.command(description="shows the user info of the person mentioned @user",
brief="shows a users info",
pass_context=True)
async def info(ctx, user: discord.Member):
"""shows the user information of the person mentioned"""
await client.say("The users name is: {}".format(user.name))
await client.say("The users ID is: {}".format(user.id))
await client.say("The users status is:{}".format(user.status))
await client.say("The user joined at:{}".format(user.joined_at))
@client.command(description="rolls a dice of d4,d6,d8,d10,d12,d20,d100",
brief="rolls a dice of specified sides",
pass_context=True)
async def roll(ctx,dice):
"""rolls a dice of sides var dice when specified"""
dicedict={"d4":random.randint(1,4),
"d6":random.randint(1,6),
"d8":random.randint(1,8),
"d10":random.randint(1,10),
"d12":random.randint(1,12),
"d20":random.randint(1,20),
"d100":random.randint(1,100)
}
await client.say("{0} you rolled a: {1}".format(ctx.message.author.mention, dicedict[dice]))
@client.command(description="randomly picks a winner from the user list",
brief="randomly picks a winner from the user list",
pass_context=True)
async def giveaway(ctx):
memberlist=[]
for member in ctx.message.server.members:
for role in member.roles:
if str(member.status) == "online" and role.name == "User":
memberlist.append(member)
await client.say("{} has won the giveaway".format(random.choice(memberlist).mention))
# used guide https://www.youtube.com/watch?v=gxKM6J5VmIc&t=708s
############################################################################################
@client.command(brief="loads command categories back")
async def load(extension):
try:
client.load_extension(extension)
except Exception as error:
print("{} cannot be loaded [{}] ".format(extension, error))
@client.command(brief="unloads command categories")
async def unload(extension):
try:
client.unload_extension(extension)
except Exception as error:
print("{} cannot be unloaded [{}] ".format(extension, error))
############################################################################################
@client.event
async def on_ready():
# says that the bot is playing a game called name
await client.change_presence(game=Game(name="Gnot a gnoblin|?help"))
# prints logged in in the terminal for the code runner to know that they logged on
print("Logged in as " + client.user.name)
if __name__ == "__main__":
for extension in extensions:
try:
client.load_extension(extension)
except Exception as error:
print("{} cannot be loaded [{}] ".format(extension, error))
@client.event
async def on_message(message):
# makes it so the bot doesn't reply to itself
if message.author == client.user:
return
# overwrites the on_message so that it can listen for bot commands
await client.process_commands(message)
client.run(TOKEN)