Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1 changed file
with
93 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
from discord.ext import commands | ||
import discord | ||
import asyncio | ||
import random | ||
from botClient import client | ||
|
||
class ErikFunctions: | ||
def __init__(self, client): | ||
self.client = client | ||
|
||
@commands.command(aliases = ['deletem']) | ||
async def clear(self, ctx, amount=100): | ||
await ctx.message.channel.purge(limit=int(amount + 1)) | ||
|
||
@commands.command() | ||
async def ping(self, ctx): | ||
await ctx.send('Pong!') | ||
|
||
@commands.command() | ||
async def echo(self, ctx, *args): # we can pass infinite amount of arguments by using *args | ||
answer = '' | ||
for word in args: | ||
answer += word | ||
answer += ' ' | ||
await ctx.send(answer) | ||
|
||
@commands.command() | ||
async def rockpaper(self, ctx): | ||
await ctx.send('Choose rock, paper or scissors.') | ||
def pred(m): | ||
return m.author == ctx.author and m.channel == ctx.channel | ||
try: | ||
msg = await client.wait_for('message', check=pred, timeout=5) | ||
except asyncio.TimeoutError: | ||
await ctx.send('Time is up.') | ||
return | ||
|
||
gamelist = ['rock', 'paper', 'scissors'] | ||
gamenumber = random.randint(0, 2) | ||
|
||
if str(msg.content) in gamelist: | ||
if str(msg.content) == str(gamelist[gamenumber]): | ||
await ctx.send("Bot chose: " + str(gamelist[gamenumber])) | ||
await ctx.send('Draw') | ||
else: | ||
await ctx.send("Bot chose: " + str(gamelist[gamenumber])) | ||
await ctx.send('Not draw') | ||
else: | ||
await ctx.send('You cannot type that') | ||
|
||
@commands.command() | ||
async def dice(self, ctx): | ||
|
||
if ctx.author.id == 326648914205736960: | ||
await ctx.send('Please choose a number between 1 - 6') | ||
|
||
def person(a): | ||
return a.author == ctx.author and a.channel == ctx.channel | ||
|
||
msg = await client.wait_for('message', check=person, timeout=5) | ||
dicenumber = random.randint(1, 6) | ||
|
||
if str(msg.content) == str(dicenumber): | ||
await ctx.send('You won') | ||
else: | ||
await ctx.send('You guessed wrong, please try again.') | ||
await ctx.send('The number was: ' + str(dicenumber)) | ||
else: | ||
await ctx.send('You dont have the permission to use this feature.') | ||
|
||
@commands.command() | ||
async def features(self, ctx): | ||
embed = discord.Embed( | ||
title='Description', | ||
description='We are giving you simple overview of the features', | ||
colour=discord.Color.purple() | ||
) | ||
|
||
embed.set_thumbnail( | ||
url='https://cdn.discordapp.com/avatars/92730223316959232/a_e088419ad7a23b58624bea79e9ebab85.webp?size=256")') | ||
embed.add_field(name='.features', value=' The bot displays the general information what he is capple of doing', | ||
inline=False) | ||
embed.add_field(name='.ping', value=' The bot says Pong', inline=False) | ||
embed.add_field(name='.echo', value=' The bot generally echoes what you have said', inline=False) | ||
embed.add_field(name='.clear', value=' The bot deletes the words you have typed.', inline=False) | ||
embed.add_field(name='.rockpaper', value=' The bot plays rock paper scissors game with you', inline=False) | ||
embed.add_field(name='.dice', value=' The bot plays dice game with you', inline=False) | ||
embed.set_footer(text=f'Requested by {ctx.message.author.name}', icon_url=ctx.message.author.avatar_url) | ||
await ctx.send(embed=embed) | ||
|
||
|
||
def setup(client): | ||
client.add_cog(ErikFunctions(client)) |