Untitled

 avatar
unknown
python
3 years ago
2.6 kB
5
Indexable
import discord
from discord import slash_command, option, ApplicationContext
from discord.ext import commands, tasks
from discord.commands import permissions
import random
import sqlite3


bot = discord.Bot() #establish discord bot
conn = sqlite3.connect("database.db") #connect to database


@bot.event
async def on_ready():
    print("ready.")
    clock.start() #start the punishment clock

@tasks.loop() #Clock cycle for expiring punishments
async def clock():
    pass

@bot.slash_command(
    guild_ids=[770441070047002656], 
    name="ping", 
    description="Responds with 'Pong' if the bot is working.") #Register the slash command
@option('content', str, description="A test string for me to echo.")
async def ping(ctx, content: str = None):
    await ctx.respond(f"šŸ“ Pong! {round(bot.latency * 1000)}ms (Version `0.0.1`)")
    if content is not None:
        await ctx.respond(f"Your test string: `{content}`",ephemeral=True)
    
@bot.slash_command(
    guild_ids=[770441070047002656], 
    name="8ball", 
    description="Ask me any question, and I will respond truthfully *sometimes*.") #Register the slash command
@option('question', str, description="The question you want me to answer 100% accurately") #Allow the user to enter their own text
async def ball(ctx, question: str): 
    possibleAnswers = ["It is certain.", "Don't count on it.", "My reply is no.", "Better not tell you now.", "Outlook good.", "Most likely.", "Yes - definitely.", "Better not tell you now.", "As I see it, yes.", "Yes", "Very doubtful.", "Signs point to yes."] #establish a list of responses
    await ctx.respond(f'ā“ <@{ctx.author.id}> asks, "{question}"\nšŸŽ± {random.choice(possibleAnswers)}') #Respond to the user

@bot.slash_command(
    guild_ids=[770441070047002656], 
    name="bully", 
    description="Bully another user, use sparingly.") #Register the slash command
@option('user', discord.User, description='The user you wish to bully.')
async def bully(ctx, user: discord.User):
    await ctx.respond(f"šŸ’¢ Bonk! <@{user.id}> has been bullied.")

@bot.slash_command(
    guild_ids=[770441070047002656], 
    name="ban", 
    description="Ban a user, permanently or temporarily.") #Register the slash command
@option('user', discord.User, description='The user you wish to ban.') #I cannot see this due to lack of permissions
@option('time', discord.User, description='The time (in days) that you wish to ban the user') #I cannot see this due to lack of permissions
async def ban(ctx, user: discord.User, time: int = 0):
    pass #put ban code here
Editor is loading...