Reputation: 1
I am making a discord.py bot and it does not "see" messages at all, it is supposed to print everything into the terminal and have a prefix, but it doesn't even print any message. code:
import datetime
import os
import discord
from timeit import default_timer as timer
from dotenv import load_dotenv
from discord.ext import commands
load_dotenv()
bot = commands.Bot(command_prefix="!")
intents = discord.Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
TOKEN = ('boop')
client = discord.Client()
@client.event
async def on_ready():
print(f'{client.user} has connected to Discord!')
async def on_message(message):
print(f'USER - {message.author} texted - {message.content}')
@bot.command()
async def start(ctx):
await ctx.channel.send("you have started")
await ctx.guild.create_role(name= {message.author} + "w")
client.run(TOKEN)
(there are extra unused modules I'm planning to use later)
Upvotes: 0
Views: 2009
Reputation: 3994
There are a few problems in your code:
commands.Bot
instance, events are not exclusive to discord.Client
.bot.process_commands
at the end of your on_message
event.@bot.event
above on_message
.ctx.guild.create_role(...)
.import discord
from discord.ext import commands
import os
import datetime
from dotenv import load_dotenv
from timeit import default_timer as timer
load_dotenv()
intents = discord.Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
@bot.event
async def on_ready():
print(f'{client.user} has connected to Discord!')
@bot.event
async def on_message(message):
print(f'USER - {message.author} texted - {message.content}')
await bot.process_commands(message)
@bot.command()
async def start(ctx):
await ctx.channel.send("You have started")
await ctx.guild.create_role(name=f"{message.author}w")
bot.run("TOKEN")
Upvotes: 1