-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot
More file actions
70 lines (50 loc) · 1.84 KB
/
bot
File metadata and controls
70 lines (50 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import discord
from discord.ext import commands
import random
import os
import requests
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix='$', intents=intents)
@bot.event
async def en_linea():
print(f'Tu bot {bot.user} esta en linea!')
@bot.command()
async def saludar(ctx,*, mensaje:str):
mensaje = mensaje.lower().strip()
if mensaje in 'hola':
await ctx.send('Hola, ¿cómo estás?')
elif mensaje in 'que onda':
await ctx.send('Todo bien')
elif mensaje in 'klk':
await ctx.send('Todo bien')
@bot.command()
async def sumar(ctx, a: float, b: float):
resultado = a + b
await ctx.send(f'La suma de {a} y {b} es {resultado}')
@bot.command()
async def mem(ctx):
with open('imagenes/mem1.jpg', 'rb') as f:
# ¡Vamos a almacenar el archivo de la biblioteca Discord convertido en esta variable!
picture = discord.File(f)
# A continuación, podemos enviar este archivo como parámetro.
await ctx.send(file=picture)
@bot.command()
async def meme_aleatori(ctx):
nombre_imagen = random.choice(os.listdir('imagenes'))
with open(f'imagenes/{nombre_imagen}', 'rb') as f:
# ¡Vamos a almacenar el archivo de la biblioteca Discord convertido en esta variable!
picture = discord.File(f)
# A continuación, podemos enviar este archivo como parámetro.
await ctx.send(file=picture)
def get_perro_imagen():
url = 'https://random.dog/woof.json'
res = requests.get(url)
data = res.json()
return data['url']
@bot.command('perro')
async def imagen_perro(ctx):
image_url = get_perro_imagen()
await ctx.send(image_url)
token = 'MTM2OTEwMzE0NzU0ODY3MjEyMA.G8ooR0.rqZ4ZZeIukSEBDF--BLG5e0kYsGqyubPXJDO0E'
bot.run(token)