I've programmed several Discord bots and am back after a long break. I am currently struggling with stuff that I used to be able to accomplish in no time. I set up my bot and added a single cog, a single test command, and a listener to feel if there is anything new but now I can't get anything to work properly. My prefix commands aren't working, messages don't seem to carry .content anymore and I can't trigger functions in my cogs.
Main file:
import nextcord as discord
from nextcord.ext import commands
intents = discord.Intents.default()
intents.message_content = True
intents.members = True
bot = commands.Bot(command_prefix = "!", intents = intents)
@bot.event
async def on_ready():
bot.load_extension("Button Roles")
print("Ready")
@bot.event
async def on_message(message):
if message.author.bot == False:
#await message.channel.send(message.content)
print(message)
@bot.command()
async def ping2(ctx):
print("Pong2!")
await ctx.send("Pong!")
bot.run("Token placeholder")
Cog:
import nextcord as discord
from nextcord.ext import commands
from nextcord import Interaction
class RoleButton(discord.ui.View):
def __init__(self):
super().__init__(timeout = None)
self.value = None
@discord.ui.button(label = "Role1", style = discord.ButtonStyle.green)#Green, Gray, Blurple, Danger
async def Role1(self, button: discord.ui.Button, i: Interaction):
await i.response.send_message("Role 1", ephemeral = True)
self.value = 1
self.stop()
@discord.ui.button(label = "Role2", style = discord.ButtonStyle.danger)#Green, Gray, Blurple, Danger
async def Role2(self, button: discord.ui.Button, i: Interaction):
await i.response.send_message("Role 2", ephemeral = True)
self.value = 2
self.stop()
class Roles(commands.Cog):
def __init__(self, bot):
self.bot = bot
print("Cog ready")
testServerId = 946874409753403422
@commands.command()
async def ping(self, ctx):
await ctx.send("Pong!")
@commands.command()
async def roleMessage(self, ctx):
view = RoleButton()
await ctx.send("You have two options:", view = view)
await view.wait()
if view.i.value == None:
return
elif view.i.value == 1:
print("Role 1!")
elif view.i.value == 2:
print("Role 2!!")
def setup(bot):
bot.add_cog(Roles(bot))
Outputs:
Cog ready
Ready
<Message id=993515538649202748 channel=<TextChannel id=946874410286084129 name='general' position=1 nsfw=False news=False category_id=946874410286084127> type=<MessageType.default: 0> author=<Member id=355727891180290070 name='ℭruenie' discriminator='8426' bot=False nick=None guild=<Guild id=946874409753403422 name="Project" shard_id=0 chunked=True member_count=4>> flags=<MessageFlags value=0>>
Expected Output (Using message.content instead of message):
Cog ready
Ready
'Hi'
#When I use !ping or !ping2 I don't get any outputs/messages
I have enabled the Intents from the Developer Portal.