-
Notifications
You must be signed in to change notification settings - Fork 10
/
discord-bot.py
90 lines (74 loc) · 2.35 KB
/
discord-bot.py
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import random
import discord
from discord.ext import commands
import asyncio
from keep_alive import keep_alive
client = commands.Bot(command_prefix = 'Your Preferred Bot Prefix')
@client.event
async def on_ready():
await client.change_presence(activity=discord.Game('Enter Anything Random Here'))
print('Connected to bot: {}'.format(client.user.name))
print('Bot ID: {}'.format(client.user.id))
@client.command(
help="Uses come crazy logic to determine if pong is actually the correct value or not.",
brief="Prints pong back to the channel."
)
async def ping(ctx):
await ctx.send(f'Pong! {round(client.latency * 1000)}ms')
@client.command()
async def hello(ctx):
await ctx.send(f'Hi!')
@client.command()
@commands.has_permissions(manage_messages = True)
async def clear(ctx, a: int):
await ctx.channel.purge(limit=1 + a)
await ctx.send(f'Channel cleared!')
@client.command(
help="Changes the nickname.",
brief="The name says it all."
)
async def nick(ctx, member : discord.Member, args):
await member.edit(nick=args)
await ctx.send(f'Nickname changed.')
@client.command(
help="Looks like you need some help, lol.",
brief="Prints the list of values back to the channel."
)
async def print(ctx, *args):
response = ""
for arg in args:
response = response + " " + arg
await ctx.channel.send(response)
@client.command(
help="Add numbers like this 'add 10 20'.",
brief="Add numbers like this 'add 10 20'."
)
async def add(ctx, a: int, b: int):
await ctx.send(a + b)
@client.command(
help="Subtract numbers like this 'sub 10 20'.",
brief="Subtract numbers like this 'sub 10 20'."
)
async def sub(ctx, a: int, b: int):
await ctx.send(a - b)
@client.command(
help="Multiplies numbers like this 'mul 10 20'.",
brief="Multiplies numbers like this 'mul 10 20'."
)
async def mul(ctx, a: int, b: int):
await ctx.send(a * b)
@client.command(
help="Divide numbers like this 'div 10 20'.",
brief="Divide numbers like this 'div 10 20'."
)
async def div(ctx, a: int, b: int):
await ctx.send(a / b)
@client.command(
help="Chooses between two options.",
brief="Chooses between two options."
)
async def choose(ctx, a: str, b: str):
list1 = [a, b]
await ctx.send(random.choice(list1))
keep_alive()
client.run('Paste Bot Token Here')