-
Notifications
You must be signed in to change notification settings - Fork 0
/
testbot.py
61 lines (42 loc) · 1.51 KB
/
testbot.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
import discord
from discord.ext import commands
import json
client = discord.Client()
bot = commands.Bot(command_prefix = ".")
@bot.event
async def on_ready():
print("Bot is ready")
@bot.event
async def on_member_join(member):
print(f"{member} has joined the server")
@bot.event
async def on_member_remove(member):
print(f"{member} has left the server")
@bot.command()
async def ping(ctx):
await ctx.send(f"ping : {round(bot.latency)*1000}ms ")
@bot.command(aliases = ["8ball" , "test"])
async def _8ball(ctx , * , question ):
await ctx.send(f"Question : {question} \n Answer : It is working")
@bot.command()
async def clear(ctx , amount = 7):
await ctx.channel.purge(limit = amount)
@bot.command()
async def kick(ctx , member : discord.Member , * , reason = None):
await member.kick(reason = reason)
@bot.command()
async def ban(ctx , member : discord.Member , * , reason = None):
await member.ban(reason = reason)
await ctx.send(f"Banned {member.mention}")
@bot.command()
async def unban(ctx , * , member):
banned_users = await ctx.guild.bans()
member_name , member_discriminator = member.split("#")
for ban_entry in banned_users:
if(ban_entry.user.name ,ban_entry.user.discriminator) == (member_name , member_discriminator):
await ctx.guild.unban(ban_entry.user)
await ctx.send(f"Unbanned {ban_entry.user.name}#{ban_entry.user.discriminator}")
return
f = open(r"E:\discord bot\token.json", )
s = json.load(f)
bot.run(s["Token"])