Replies: 3 comments
-
It is slightly hard to read because of the weird formatting, but it seems you don't have a cog setup function. You can't just do bot.add_cog, you have to wrap it in a setup function. You can find an example here |
Beta Was this translation helpful? Give feedback.
-
There are a lot of things going on here. And it is really hard to read because you didn't use code blocks or have things indented. async def load():
for filename in os.listdir("./cogs"):
if filename.endswith(".py") and not filename.startswith('__'):
await bot.load_extension("cogs.{0}".format(filename[:-3])) But this function is never called anywhere. Make sure to actually call the function. Better still, you should look into making a subclass of the bot so you can override setup_hook. On another note, it looks like you are making another bot in your cog"?" When you load the extension, it will handle passing the bot along if you have a section like: async def setup(bot: commands.Bot) -> None:
await bot.add_cog(MyCog(bot)) A great read-up you should look into is Slash Commands and you by AbstractUmbra . It should have a lot of good examples. |
Beta Was this translation helpful? Give feedback.
-
thats not how application commands in discord.py work. you can find better guidance in the official discord (.gg/dpy) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
im creating a bot, but it cant find any command that is in a cog. i've tried everything, here's my code
main:
import discord
import os
import asyncio
from discord.ext import commands
TokenFile = open("./data/Token.txt", "r")
TOKEN = TokenFile.read()
OWNERID = 755431789987758140
intents = discord.Intents.all()
bot = commands.Bot(command_prefix="!", help_command=None,intents=intents)
async def load():
for filename in os.listdir("./cogs"):
if filename.endswith(".py") and not filename.startswith('__'):
await bot.load_extension("cogs.{0}".format(filename[:-3]))
@bot.event
async def on_ready():
print('Logged in as')
print(bot.user.name)
print(bot.user.id)
print('------')
@bot.command(name='ping')
async def ping(ctx):
await ctx.send(f'Pong! Latency: {round(bot.latency * 1000)}ms')
bot.run(str(TOKEN))
cog:
import random
import discord
from discord.ext import commands
from discord import slash_command
intents = discord.Intents.all()
bot = commands.Bot(command_prefix="!", intents=intents)
sites = ["https://longdogechallenge.com/",
"http://heeeeeeeey.com/",
"http://corndog.io/",
"https://mondrianandme.com/",
"https://puginarug.com",
"https://alwaysjudgeabookbyitscover.com",
"https://thatsthefinger.com/",
"https://cant-not-tweet-this.com/",
"http://eelslap.com/",
"http://www.staggeringbeauty.com/",
"http://burymewithmymoney.com/",
"https://smashthewalls.com/",
"https://jacksonpollock.org/",
"http://endless.horse/",
"https://www.trypap.com/",
"http://www.republiquedesmangues.fr/",
"http://www.movenowthinklater.com/",
"http://www.partridgegetslucky.com/",
"http://www.rrrgggbbb.com/",
"http://beesbeesbees.com/",
"http://www.koalastothemax.com/",
"http://www.everydayim.com/",
"http://randomcolour.com/",
"http://cat-bounce.com/",
"http://chrismckenzie.com/",
"https://thezen.zone/",
"http://hasthelargehadroncolliderdestroyedtheworldyet.com/",
"http://ninjaflex.com/",
"http://ihasabucket.com/",
"http://corndogoncorndog.com/",
"http://www.hackertyper.com/",
"https://pointerpointer.com",
"http://imaninja.com/",
"http://drawing.garden/",
"http://www.ismycomputeron.com/",
"http://www.nullingthevoid.com/",
"http://www.muchbetterthanthis.com/",
"http://www.yesnoif.com/",
"http://lacquerlacquer.com",
"http://potatoortomato.com/",
"http://iamawesome.com/",
"https://strobe.cool/",
"http://www.pleaselike.com/",
"http://crouton.net/",
"http://corgiorgy.com/",
"http://www.wutdafuk.com/",
"http://unicodesnowmanforyou.com/",
"http://chillestmonkey.com/",
"http://scroll-o-meter.club/",
"http://www.crossdivisions.com/",
"http://tencents.info/",
"https://boringboringboring.com/",
"http://www.patience-is-a-virtue.org/",
"http://pixelsfighting.com/",
"http://isitwhite.com/",
"https://existentialcrisis.com/",
"http://onemillionlols.com/",
"http://www.omfgdogs.com/",
"http://oct82.com/",
"http://chihuahuaspin.com/",
"http://www.blankwindows.com/",
"http://dogs.are.the.most.moe/",
"http://tunnelsnakes.com/",
"http://www.trashloop.com/",
"http://www.ascii-middle-finger.com/",
"http://spaceis.cool/",
"http://www.donothingfor2minutes.com/",
"http://buildshruggie.com/",
"http://buzzybuzz.biz/",
"http://yeahlemons.com/",
"http://wowenwilsonquiz.com",
"https://thepigeon.org/",
"http://notdayoftheweek.com/",
"http://www.amialright.com/",
"http://nooooooooooooooo.com/",
"https://greatbignothing.com/",
"https://zoomquilt.org/",
"https://dadlaughbutton.com/",
"https://www.bouncingdvdlogo.com/",
"https://remoji.com/",
"http://papertoilet.com/", ]
ois_do_bot = ['oi', 'eae', 'eai', 'opa', 'epa', 'yo', 'alou', 'ola', 'Olá', 'epa', 'manda a braba', 'fala fi',
'opa, bom?', 'oi, como estais?', 'chamou?']
respostas = ['Não respondo a isso', 'Sim', 'As vezes', 'Não', 'Claro', 'NUNCA!', 'Um dia talvez',
'A resposta está dentro de vc', 'Mais ou menos', 'Podia ser pior']
class Fun(commands.Cog):
"""
fun commands to make you happy 😁
"""
def init(self, bot):
self.bot = bot
self._last_member = None
bot.add_cog(Fun(bot))
Beta Was this translation helpful? Give feedback.
All reactions