-
Notifications
You must be signed in to change notification settings - Fork 43
/
spam.py
36 lines (28 loc) · 939 Bytes
/
spam.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
import discord
from discord.ext import commands
import asyncio
import json
pingr = commands.Bot(command_prefix="_", help_command=None)
# https://github.com/G-eb/
with open("config.json") as f:
geb = json.load(f)
guildid = int(geb["spam_guild_id"])
roleid = geb["ping_role_id"]
bottoken = geb["bot_token"]
async def ping_task():
while True:
guild = pingr.get_guild(guildid)
for channel in guild.channels:
if isinstance(channel, discord.TextChannel):
if channel.name.startswith('ping'):
await channel.send(f"<@&{roleid}>")
await asyncio.sleep(0.1)
else:
pass
@pingr.event
async def on_ready():
pingr.loop.create_task(ping_task())
@pingr.slash_command(guild_ids=[guildid])
async def ping(ctx):
await ctx.respond(f"{round(pingr.latency * 1000)}ms")
pingr.run(bottoken)