Skip to content
Permalink
master
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
import random
import discord
from discord.ext import commands
import requests
from lxml import html
class Random:
def __init__(self, client):
self.client = client
# ahmed's
@commands.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(self, 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 self.client.say("{0} {1}".format(ctx.message.author.mention, random.choice(guesscountry)))
# seva's
@commands.command(description="takes a random joke from a list",
brief="says a random joke",
pass_context=True)
async def joke(self, 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 self.client.say("{0} {1}".format(ctx.message.author.mention, random.choice(jokes)))
# ahmed's
@commands.command(description="takes a random fact from a list",
brief="says a random fact",
pass_context=True)
async def facts(self, 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 self.client.say("{0} {1}".format(ctx.message.author.mention, random.choice(facts)))
@commands.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(self, 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 self.client.say("{0} you rolled a: {1}".format(ctx.message.author.mention, dicedict[dice]))
@commands.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(self, 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 self.client.say("{} has won the giveaway".format(random.choice(memberlist).mention))
def setup(client):
client.add_cog(Random(client))