Discord Python Bot only responds to dms
Question:
The bot has admin perms, I have no idea why it would do this, seems really weird… any ideas would be great……
This code was generated by ChatGPT btw
Hsggsss hshsssggs
Shsyshgsvsvevsgs
Jshsgscsccsvshshshyw
Hshshsggsfsgs
import discord
import random
from discord.ext import commands
# Define your phrases in a dictionary where the keys are the phrases
# and the values are the corresponding article names
phrases = {
"Phrase 1": "Article 1",
"Phrase 2": "Article 2",
"Phrase 3": "Article 3",
"Phrase 4": "Article 4"
}
intents = discord.Intents.default()
intents.members = True
bot = commands.Bot(command_prefix='!', intents=intents)
@bot.command(name='phrase')
async def get_random_phrase(ctx):
# Get a random phrase from the dictionary
random_phrase = random.choice(list(phrases.keys()))
article_name = phrases[random_phrase]
# Send the random phrase
message = await ctx.send(f"Here's a random phrase: {random_phrase}")
def channel_filter(m):
# Check if the message is correct and from the correct user and in the same server and channel
return m.author != bot.user and m.guild == ctx.guild and m.channel == ctx.channel and m.content.lower() == article_name.lower()
try:
# Wait for a correct message for 30 seconds
message = await bot.wait_for('message', timeout=30.0, check=channel_filter)
# If a correct message is received, send a response
await ctx.send(f"{message.author.mention}, that is correct!")
except:
# If no correct message is received, send a timeout message
await ctx.send("Time's up!")
I tried re inviting the bot to the server, but still won't work.
Answers:
You probably need the message_content
intent.
Add this to your code:
intents.message_content = True
Also go to the Developer Portal https://discord.com/developers/applications and the bot section and enable message_content
The bot has admin perms, I have no idea why it would do this, seems really weird… any ideas would be great……
This code was generated by ChatGPT btw
Hsggsss hshsssggs
Shsyshgsvsvevsgs
Jshsgscsccsvshshshyw
Hshshsggsfsgs
import discord
import random
from discord.ext import commands
# Define your phrases in a dictionary where the keys are the phrases
# and the values are the corresponding article names
phrases = {
"Phrase 1": "Article 1",
"Phrase 2": "Article 2",
"Phrase 3": "Article 3",
"Phrase 4": "Article 4"
}
intents = discord.Intents.default()
intents.members = True
bot = commands.Bot(command_prefix='!', intents=intents)
@bot.command(name='phrase')
async def get_random_phrase(ctx):
# Get a random phrase from the dictionary
random_phrase = random.choice(list(phrases.keys()))
article_name = phrases[random_phrase]
# Send the random phrase
message = await ctx.send(f"Here's a random phrase: {random_phrase}")
def channel_filter(m):
# Check if the message is correct and from the correct user and in the same server and channel
return m.author != bot.user and m.guild == ctx.guild and m.channel == ctx.channel and m.content.lower() == article_name.lower()
try:
# Wait for a correct message for 30 seconds
message = await bot.wait_for('message', timeout=30.0, check=channel_filter)
# If a correct message is received, send a response
await ctx.send(f"{message.author.mention}, that is correct!")
except:
# If no correct message is received, send a timeout message
await ctx.send("Time's up!")
I tried re inviting the bot to the server, but still won't work.
You probably need the message_content
intent.
Add this to your code:
intents.message_content = True
Also go to the Developer Portal https://discord.com/developers/applications and the bot section and enable message_content