-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
51 lines (35 loc) · 1.13 KB
/
main.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
import discord
from discord.ext import commands, tasks
prefix = '!'
intents = discord.Intents.default()
intents.message_content = True
client = commands.Bot(command_prefix=prefix, intents=intents)
ping_loops = []
@client.event
async def on_ready():
print("Bot is online!")
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name='For !ping'))
@client.command()
async def reply(ctx):
await ctx.reply("I'm replying to you!")
@client.command()
async def test(ctx):
await ctx.send("The bot is working!")
await ctx.send(f"Bot ping is {round(client.latency * 1000)} ms <@{ctx.author.id}>")
@client.command()
async def say(ctx, *, message):
await ctx.send(message)
@client.command()
async def ping(ctx):
async def ping_loop():
await ctx.send(ctx.message.content.replace("!ping", ""))
ping_loop_task = tasks.loop(seconds=1.5)(ping_loop)
ping_loop_task.start()
ping_loops.append(ping_loop_task)
@client.command()
async def stop(ctx):
for loop in ping_loops:
loop.cancel()
ping_loops.clear()
await ctx.reply("Stopped.")
client.run("BOT-TOKEN")