Basic functionality
!roll !ping Hiding token
This commit is contained in:
@@ -158,3 +158,6 @@ cython_debug/
|
|||||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||||
#.idea/
|
#.idea/
|
||||||
|
|
||||||
|
# token
|
||||||
|
/discordtoken
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
from discord.ext import commands
|
||||||
|
import discord
|
||||||
|
import os
|
||||||
|
import asyncio
|
||||||
|
from discordtoken import discordtoken
|
||||||
|
|
||||||
|
client = commands.Bot(command_prefix="!", intents=discord.Intents.all())
|
||||||
|
|
||||||
|
@client.event
|
||||||
|
async def on_ready():
|
||||||
|
print("Succes: Bot has started working")
|
||||||
|
|
||||||
|
async def load():
|
||||||
|
for filename in os.listdir("./cogs"):
|
||||||
|
if filename.endswith(".py"):
|
||||||
|
await client.load_extension(f"cogs.{filename[:-3]}")
|
||||||
|
|
||||||
|
async def main():
|
||||||
|
async with client:
|
||||||
|
await load()
|
||||||
|
await client.start(discordtoken.get())
|
||||||
|
|
||||||
|
asyncio.run(main())
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import discord
|
||||||
|
from discord.ext import commands
|
||||||
|
|
||||||
|
class Ping(commands.Cog):
|
||||||
|
def __init__(self, client):
|
||||||
|
self.client = client
|
||||||
|
|
||||||
|
@commands.Cog.listener()
|
||||||
|
async def on_ready(self):
|
||||||
|
print("Ping.py is ready")
|
||||||
|
|
||||||
|
@commands.command()
|
||||||
|
async def ping(self, ctx):
|
||||||
|
bot_latency = round(self.client.latency * 1000)
|
||||||
|
await ctx.send(f"pong! {bot_latency}ms.")
|
||||||
|
|
||||||
|
|
||||||
|
async def setup(client):
|
||||||
|
await client.add_cog(Ping(client))
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
import discord
|
||||||
|
from discord.ext import commands
|
||||||
|
import random
|
||||||
|
|
||||||
|
class Roll(commands.Cog):
|
||||||
|
def __init__(self, client):
|
||||||
|
self.client = client
|
||||||
|
|
||||||
|
@commands.Cog.listener()
|
||||||
|
async def on_ready(self):
|
||||||
|
print("roll.py is ready")
|
||||||
|
|
||||||
|
@commands.command()
|
||||||
|
async def roll(self, ctx):
|
||||||
|
rolled = random.randint(1,100)
|
||||||
|
rating = ""
|
||||||
|
|
||||||
|
if(rolled == 100):
|
||||||
|
rating = "What a chad"
|
||||||
|
elif(rolled < 100 and rolled > 90):
|
||||||
|
rating = "Almost"
|
||||||
|
elif(rolled <= 90 and rolled > 80):
|
||||||
|
rating = "Good"
|
||||||
|
elif(rolled <= 80 and rolled > 69):
|
||||||
|
rating = "Alright"
|
||||||
|
elif(rolled == 69):
|
||||||
|
rating = "Nice"
|
||||||
|
elif(rolled < 69 and rolled > 50):
|
||||||
|
rating = "Decent"
|
||||||
|
elif(rolled <= 50 and rolled > 25):
|
||||||
|
rating = "Meh"
|
||||||
|
elif(rolled <= 25 and rolled > 1):
|
||||||
|
rating = "Almost"
|
||||||
|
elif(rolled == 1):
|
||||||
|
rating = "LOL"
|
||||||
|
|
||||||
|
message = "You rolled " + str(rolled) + ", " + rating
|
||||||
|
|
||||||
|
await ctx.send(message)
|
||||||
|
|
||||||
|
|
||||||
|
async def setup(client):
|
||||||
|
await client.add_cog(Roll(client))
|
||||||
Reference in New Issue
Block a user