Untitled
unknown
plain_text
4 years ago
2.9 kB
11
Indexable
import discord
from discord import Embed, Member
from discord.ext import commands
import time
import asyncio
import json
import os
import audioread
import datetime
import random
# console formatting
W = "\033[0m" # white (normal)
R = "\033[31m" # red
G = "\033[32m" # green
O = "\033[33m" # orange
B = "\033[34m" # blue
P = "\033[35m" # purple
prefix = "*"
client = commands.Bot(command_prefix=prefix, help_command=None)
try:
with open('./config/secrets.json') as f:
secrets = json.load(f)
except ValueError:
print('Failed to load jsons')
# clear temp folder
for f in os.listdir("./temp"):
if f.startswith(".git"):
continue
os.remove(os.path.join("./temp", f))
@client.event
async def on_ready():
# Hello World :-)
botname = client.user.name
print("Bot" + R + f" {botname} " + W + "is ready!")
servers = f"{botname} is on the following servers: " + B + \
f'{W}, {B}'.join([str(x) for x in client.guilds]) + W
print(servers)
# calculate latency
ping_ = client.latency
ping = round(ping_ * 1000)
print("Latency: " + O + f"{ping}" + "ms" + W)
# empty line
print("\n")
# status task
client.loop.create_task(status_task())
async def status_task():
while True:
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="polytune.exe"),
status=discord.Status.online)
await asyncio.sleep(5)
@client.command(name="help", aliases=["h"])
async def help(ctx):
await polytune(ctx, sfx_file="help")
@client.command(name="ping")
async def ping(ctx):
ping_ = client.latency
ping = round(ping_ * 1000)
await ctx.send(f"Pong! :stopwatch: {ping}ms")
@client.command(name="polytune", aliases=["poly", "p"])
async def polytune(ctx, sfx_file=None, prev=None):
@client.command(name="leave", aliases=["l"])
async def leave(ctx):
def to_codelist_dir(dirpath):
async def add_emoji_success(ctx):
async def bad_trolling(ctx):
async def bad_custom_audio(ctx, remove_filelocation=None):
@client.event
async def on_command_error(ctx, error):
@client.event
async def on_message(message):
if client.user.mentioned_in(message):
await message.channel.send("My pronoun is `" + prefix + "`")
await client.process_commands(message)
# special feature
@client.event
async def on_reaction_add(reaction, user):
print("test")
if (reaction.emoji.id == 852891495702462465) and (reaction.message.id == 852892915864567818): # and (user.id != 567387950308917268)
await reaction.remove(user)
# @client.event
# async def on_voice_state_update(member, before, after):
# if member == client.user:
# if after.channel is None:
# voice = discord.utils.get(client.voice_clients, guild=before.channel.guild)
client.run(secrets['bot']['token'])Editor is loading...