import discord, os, time, random, string, asyncio, datetime, typing
import config
from discord.ext import commands
from discord import DMChannel
intents = discord.Intents.all()
bot = commands.Bot(command_prefix=';', intents=intents)
@bot.event
async def on_ready():
await bot.change_presence(activity=discord.Game('Start with ;info !'))
print("{bot.user.name} is up and runing!")
print(f"_________________________________")
#Info command
@bot.command()
async def info(ctx):
embed = discord.Embed(
colour=discord.Colour.purple(),
description="Welcome to Infinity.\n\n**What is Infinity?**\n Infinity is a bot that support mental health!\n\n**How dose it help?**\n Infinity helps by being there to cheer you up, and there will always be a support person there to talk to.\n\n**How dose someone talk to you through the bot?**\n The bot uses a DM system where you can DM the bot and it will go to one of our support team members. \n\n **How do I report a bug or someone using the bot?**\n You may use our support server to report bugs or someone who uses the bot.",
title="Hello, I am Infinity!"
)
embed.set_thumbnail(url="https://cdn.discordapp.com/attachments/1142857962172457102/1142891040781635634/Infinity.png")
await ctx.reply(embed=embed)
#More commands
@bot.command()
async def quote(ctx):
embed = discord.Embed(
colour=discord.Colour.purple(),
description="You're braver than you believe, and stronger than you seem, and smarter than you think",
title="Quote of the Day!"
)
embed.set_footer(text="20/08/23")
await ctx.reply(embed=embed)
#DM System
@bot.event
async def on_message(message):
if message.author == bot.user:
return
if str(message.channel.type) == "private":
dm_channel = discord.utils.get(bot.get_all_channels(), name="dm-system-test")
await dm_channel.send("[" + message.author.display_name + "]" + message.content)
elif str(message.channel) == "dm-system-test" and message.content.startswith("<"):
member_object = message.mentions[0]
index = message.content.index(" ")
string = message.content
mod_message = string[index:]
await member_object.send("[" + message.author.display_name + "]" + mod_message)
await bot.process_commands(message)
bot.run(config.TOKEN)
I tried making a DM system after making a few commands, then I tested out the DM's system it worked but my other commands didn't. I have posted my code above just so you can look at it for any errors, that is all my code there is nothing else to it. (I have a seperate config section for my token)
This line await bot.process_commands(message)
is indented incorrectly.
It should be at the same level as your if message.author == bot.user:
statement.
Correct this and it should work.