#discord-bots
1 messages · Page 436 of 1
Huh?
Ah yea
A fork which changed discord.gg links with pda.gg lol 
What's that?
One out of 3k forks
whose
One of my friends'
Ah ok
They created a support bot and a 29 level boosted "support" server without implementing anything in fork

@visual island when I added it, errors handling seriously slowed down, and by seriously I mean it started taking over 3 seconds for bot to respond, and exception still wasn't handled
Very weird
Wdym
if isinstance(error, discord.Forbidden):
# do something
NotFound* in their case
😐
inside the command a bare try/except always works to stop showing the error
With getattr uncommented it takes too long to respond
And handler for discord.NotFound still doesn't work
Ignore that error.error
And if
Nvm I managed to fix it
Thx for help
How can I make a bot? And a website together?
Like implementing your bot inside the website or reverse?
Depends on what you want
Ye
^^^
Like in 1 file my bot and website
Those are 2 questions 
Oh sorry
make the website with whatever framework you're making and implement bot inside that

Oh
Actually No
What framework you're using to make site?
I used subprocess, quart, quart-discord and discord-ext-ipc to do this.
Also it's better to have them separately and implement API into your site to communicate with your bot
?? IPC routes is way faster
Hey
Can someone help please, I have installed DiscordUtils but
import DiscordUtils```
Doesn't work
I got an error
what theme is that 👀
ModuleNotFoundError: No module named 'cogs.'
Let me check
I think it's darcula
uhm
Idk how I got it
Does someone know what's the issue?
How about uninstall it and clear the cache then install it again?
Which error tho
I mean
Cannot find module?
Yes
Sure
can you give me the ss/text of the error
yes
wait a sec
Sorry for missunterstanding, it doesn't give me an error, just shows in the "problems console" - idk how to name it
¯_(ツ)_/¯
Can you try run the index.py/bot.py first
And run the command
Then check if there's any error
Ok
"cogs."
Wasn't it "cogs"
Alr
yeah, but idk why is saying it's a module what in reality it's a folder with the commands
Can you try use pip uninstall cogs
I have this:
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
client.load_extension(f'cogs.{filename[-3]}')
Then clear your local caches
a module is also a folder with python files
show your tree
Why don't you do it on vs code on your local machine first-
coding on a cloud is worsts idea
I had the same error, wait
for filename in os.listdir('cogs',):
if filename.endswith('.py'):
client.load_extension(f'cogs.{filename[:-3]}')```
Try this
works for me
¯_(ツ)_/¯
ಠ_ಠ
ಠ_ಠ
/╲/\╭(•‿•)╮/\╱\
cool emoji
wtf
?
lol
nothing
S P I D E R
By some reason, the error have changed
Show
Show

Extension 'cogs.participate' has no 'setup' function.
cogs sometimes it is confused
Don't iterate over the folder using os listdir
Did you added the
def setup(client):
client.add_cog(someting(client))```
something
Your class instance.
Yes
Indeed
No it's your class instance
Oh right
Don't spread misinformation.
srry
Why shitpost here
@south kayak pls delete the GIF(s) from here. This isn't the correct place to do so
Thanks
ok ok
Also anyway to check the args and then output it as different message for different args
like this? Idk if it works or not
@bot.command()
@commands.check(simple_check)
async def error(ctx, *, args):
if args == "attribute":
await ctx.sen("ez")
if args == "def":
await ctx.send(ez)
What is sen?
I have the catching error one so-
I want it to be like that
Ignore it
What variable is ez?
Basically it's error generator some cringy command that i was doing
Is it correct to use "if" like that?
Just asking only the "if" part-
yo i tried hosting my bot on heroku but it aint working
Lemme try run it ig
it shows "no bot token found"
Well mostly we use elif when working with multiple statements.
even tho i have the bot token
i have config.py
Did you properly check the main file?
but in heroku or zeplit it doesnt work
yeap thrice
oh this is my error
show it when
'Music' object has no attribute 'create'```
Sorry but what doest it mean?
I dont' understand
Can you send your command code
one min
Sure
import discord
from discord.ext import commands
import time
import youtube_dl
import ffmpeg
import DiscordUtils
from discord.user import User
from discord.utils import get
from discord import FFmpegPCMAudio
class music(commands.Cog):
def __init__(self, client):
self.client = client
@commands.command()
async def play(self, ctx, *, url):
music = DiscordUtils.Music()
player = music.get_player(guild_id=ctx.guild.id)
if not player:
player = music.create.player(ctx, ffmpeg_error_batterfix=True)
if not ctx.voice_client.is_playing:
await player.queue(url, search=True)
song = await player.play()
await ctx.reply(f'Playing: `{song.name}`')
else:
song = await player.queue(url, search=True)
await ctx.reply(f'`{song.name}`` has been added to the queue')
def setup(client):
client.add_cog(music(client))```
When I activate the bot it's perfectly fine
But when i use.music
lemme read
Ok srry
Basically yes
when you start it run only main one
But if you run command it run the command code
yes
@commands.Cog.listener()
async def on_message(self, message):
if message.author == self.bot.user:
return
if message.content.startswith('☑️'):
await message.author.send('Hello!')
await message.delete(message)```
await message.delete(message)
TypeError: delete() takes 1 positional argument but 2 were given```
how to delete message in on_message?
Have you ever declare the "create" one
and what is it
in the logs i mean
What do you mean?
ill try that
Bot doesn't know what is "create"
Idk
I'm not similar to music bot
Let other people handle it
ok
Wait a sec
Ah
yep yep yep
@slate swan do you have the "Procfile"
Did you disable the default dyno one
there wasny a default dyno
If no then do it
it was empy
The top one is the default
But when you put procfile
The bottom one will appear
Also
Can you try delete the token in config.py and put it straight in the main one instead
it is in the main one
<yoursomething>.run('<token>')
i know
I think i fixed it, but i got another error 
AttributeError: type object 'music'
has no attribute 'get_player'```
client.run('token')
lmao idk what about it now
ohh fuk i used to have that error too
Did you put any bot event
get_player aint found
yea there is
Download git
i have it
Do you have git on your pc?
You fixed it?
heroku login
oh alright one minute
well i think for me it wass cuzz i didnt import something
heroku login
heroku git:remote <your_app_name>
heroku logs --tail
Do this and send me the error/text

embed.add_field(name="Invite the bot", value="DISCORDBOT INVITE LINK", inline=True)
embed.add_field(name="Join the Discord Server", value="DISCORD INVITE LINK", inline=True)
embed.set_footer(text="Created by ItsNyoty | Copyrighted by MovieBot")
await ctx.send(embed=embed)```
its stuck here
File "main.py", line 836
embed=discord.Embed(title="Invites link", description="This is a list of invites")
^
IndentationError: expected an indented block
ohkay
Indent it properly
Open another git bash
wdym
yes?
ohh i gotta dfo the rest
I'm looking for help in internet
And i found... || nothing ||

Try look up on Just some bot git repo
The example bot
If you can't find any help then try search for an example bot
is there anyone who can help me with something?
Did you uh
do the git remote one
ok
heroku git:remote -a (your app name here)
these intends are good???
u mean my bot's name?
The name on heroku
ohkay
can anyone help me with something how do i disable using commands in dms?
I managed to get the load_extension work but: discord.ext.commands.errors.CommandNotFound: Command "register" is not found
@commands.guild_only
whoops
lemme check again hold on
so i just put this @commands.guild_only?
heroku....
Copy and paste this
heroku git:remote -a (yourappname)
put your app name at the back section
I think my loading command event is not working...
@commands.guild_only()
put it below the client.command()
ahh leave it but thank you for your help
Alr
send ur line 35 whole code part
@eager bolt
@something.command()
@commands.guild_only()
async def steam(ctx):
//your code
Replace something with bot or client or something that you used
its alright i fixed it alr.
he wants it as mee6 ig
dayum
how do i kick somebody from a vc?
@unkempt canyon
prefix?
!discord.VoiceText
i meant
The prefix is !
!d discord.VoiceChannel
class discord.VoiceChannel```
Represents a Discord guild voice channel.
`x == y` Checks if two channels are equal.
`x != y` Checks if two channels are not equal.
`hash(x)` Returns the channel’s hash.
`str(x)` Returns the channel’s name.
!d discord.Member.edit
await edit(*, reason=None, **fields)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the member’s data.
Depending on the parameter passed, this requires different permissions listed below...
You can do edit(voice_channel=None)
tnx also . i can edit member overwrite like (only member)
Like this
await member_to_kick.edit(voice_channel=None)
replace "member_to_kick" to yours
i did
Hi, how could I get someones activity and know if its playing a game or streaming?? Because I see in the docs that there are several categories, but can't figure out how to access them, like for example to get the stream url, or the game name, thanks in advance.
This are the categories I refer to:
sqlite3.OperationalError: database is locked
What it's mean
They can help you with that better here -> #databases
Guys, is there any way, i take input from the user from a dm and send it in a specific channel in a server
What is the event called when a new member joins the server?
async def on_member_join(member):
#do stuff
!d discord.on_member_join
discord.on_member_join(member)``````py
discord.on_member_remove(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Member "discord.Member") leaves or joins a [`Guild`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Guild "discord.Guild").
This requires [`Intents.members`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Intents.members "discord.Intents.members") to be enabled.
thanks
Anyone?
!d discord.ext.commands.Bot.wait_for
wait_for(event, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.
The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.
In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/stable/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
.....
Either a dms only command or use wait_for.
I understand that stuff, but i want to send a message to a specific server, when they write the command
i need someone to learn me how to create a discord bots by python
!d discord.Client.get_guild
teach*
get_guild(id)```
Returns a guild with the given ID.
ohhhh. i see, thanku bhaiya
bhaiya*? 
from where ?
haha, bhaiya means brother
youtube?
Ik ik 
Do you know Python with some basic concepts and basic OOP and inheritance?
iam learning python , iam still in modules
then continue learning
and don't jump in discord.py since it's a hard lib for beginners
^ You must know more then ig
oop no i dont have any info about
^
Hi, how could I get someones activity and know if its playing a game or streaming?? Because I see in the docs that there are several categories, but can't figure out how to access them, like for example to get the stream url, or the game name, thanks in advance.
This are the categories I refer to:
Can u turn on dark mode?
!d discord.Member.activity
activity```
Returns the primary activity the user is currently doing. Could be `None` if no activity is being done.
Note
Due to a Discord API limitation, this may be `None` if the user is listening to a song on Spotify with a title longer than 128 characters. See [GH-1738](https://github.com/Rapptz/discord.py/issues/1738) for more information.
Note
A user may have multiple activities, these can be accessed under [`activities`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Member.activities "discord.Member.activities").
Hello
The activities that the user is currently doing.
Note
Due to a Discord API limitation, a user’s Spotify activity may not appear if they are listening to a song with a title longer than 128 characters. See GH-1738 for more information.
There
better now? 😆
218454818404614840108181 times better
And yea, that ain't a random number, definitely not

some people prefer light mode
it's brighter than the sun
Light mode not that bad
you can't force them to switch just because you dont like it
Can I make my discord bot appear connected from cell phone?
I just asked them... If they didn't want to switch, they could have also said No
yellow mode 
I use light mode for replit 
Monkepatching
Hey @valid patio! I noticed you posted a seemingly valid Discord API token in your message and have removed your message. This means that your token has been compromised. Please change your token immediately at: https://discordapp.com/developers/applications/me
Feel free to re-post it with the token removed. If you believe this was a mistake, please let us know!
Lol
who is this?
Light mode
lmao
its not that bad
😂that's a way to edit the library locally
Eh, not in the daytime. But I get a headache for a long use of light mode
and i needs install ;/?
dont monkeypatch, it's not recommended and you can easily break something if you don't know what you're doing
and danny hates it
How can I know if the activity of a user is in the Streaming Category?? To get the streaming url and those things
do you need me to call an ambulance for you?
Even if they darken the color a bit, like of the message box, light mode will be 100 times better 
Yea
!d discord.Member.activities
The activities that the user is currently doing.
Note
Due to a Discord API limitation, a user’s Spotify activity may not appear if they are listening to a song with a title longer than 128 characters. See GH-1738 for more information.
They return the list of activities
Use a loop and check each element with isinstance()
why did i get ?
Your var is none
Discord themselves has made light mode bad
the env var doesn't exists
@client.event
async def on_ready():
await client.change_presence(activity=discord.Streaming(name=f'{len(client.guilds)} server', url="url")
print(f"logged{client.user}.")
How do I get this to be updated?
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
i am making a /report command and i want to send the report to the #reports channel
Don't change_presence in on_ready, instead set it as activity kwarg in bot constructor
To get updated, make a task
0k
Why not set the status in a task and start it...? That way, u will set the status as well as update it
Yes, but how do I do it?
!d discord.ext.tasks.Loop
class discord.ext.tasks.Loop```
A background task helper that abstracts the loop and reconnection logic for you.
The main interface to create this is through [`loop()`](https://discordpy.readthedocs.io/en/stable/ext/tasks/index.html#discord.ext.tasks.loop "discord.ext.tasks.loop").
anyone know how?
!d discord.Guild.get_channel
get_channel(channel_id)```
Returns a channel with the given ID.
!d discord.TextChannel.send
await send(content=None, *, tts=False, embed=None, file=None, files=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.
To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/stable/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/stable/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.
If the `embed` parameter is provided, it must be of type [`Embed`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Embed "discord.Embed") and it must be a rich embed type.
it is a slash command
await inter.reply(embed=sus, ephemeral=True)
how do i put the channel in there lol

dislash
Ah
yes
I think it's inter.respond.
channel = inter.guild.get()
^ what Hunter said
Or channel = inter.channel?
No
Wait that's hunter, nevermind.
i want to send to specific channel
He wants to send the report in a specific channel
yeah
Aah okay. Got it.
@fair axle interaction?
channel = client.get_channel(id)
await channel.send()
? wdym
What parameter using?
inter, user, reason=None
This part not working?
no just was asking questions it has been answered thanks
Got it
@Client.command()
async def resports(ctx, arg):
channelid = "your channel id of reports"
await channelid.send(arg)
:)
i do in 1 minute
You must get channel using get_channel method
you needs add content
!d discord.Guild.get_channel
get_channel(channel_id)```
Returns a channel with the given ID.
I thought it was for a specific channel to send the message
...
bot says ffmpeg not found when i try to play music :( welp
like this?
channel = inter.guild.get_channel(ID)
await channel.send(f"i am big brain")
Yes
'str' object has no attribute 'send'
Hello. I want write discord bot for moderation. How ban, kick or change roles for users?
I dont know how make commands for ban for a certain period, kick or change role for a certain period.
I just dont know correctly English :)
)))))))))))))))
wait answer...
!d discord.Member.ban
await ban(**kwargs)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Bans this member. Equivalent to [`Guild.ban()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Guild.ban "discord.Guild.ban").
!d discord.Member.kick
await kick(*, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Kicks this member. Equivalent to [`Guild.kick()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Guild.kick "discord.Guild.kick").
!d discord.Member.add_roles
await add_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Role "discord.Role")s.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
!d discord.Member.remove_roles
Thank you!
await remove_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Removes [`Role`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Role "discord.Role")s from this member.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the removed [`Role`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
If you mean something like this, I have already tried and returns an error as Streaming is not defined if isinstance(after.activity, Streaming):
discord.Streaming
!d discord.Streaming
class discord.Streaming(*, name, url, **extra)```
A slimmed down version of [`Activity`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Activity "discord.Activity") that represents a Discord streaming status.
This is typically displayed via **Streaming** on the official Discord client.
`x == y` Checks if two streams are equal.
`x != y` Checks if two streams are not equal.
`hash(x)` Returns the stream’s hash.
`str(x)` Returns the stream’s name.
Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\Hp\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "D:\pythonProject\discord bot\Ansinator.py", line 14, in on_message
if message.conent.startswith('$github'):
AttributeError: 'Message' object has no attribute 'conent'
Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\Hp\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "D:\pythonProject\discord bot\Ansinator.py", line 14, in on_message
if message.conent.startswith('$github'):
AttributeError: 'Message' object has no attribute 'conent'
Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\Hp\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "D:\pythonProject\discord bot\Ansinator.py", line 14, in on_message
if message.conent.startswith('$github'):
AttributeError: 'Message' object has no attribute 'conent'
why did this come ?
???????????????????????????????????????????????????????//
check the bold section
there is nothing as conent
its content
Does anyone know why does doesn't work?
# Commands
@bot.command(name='n')
async def n(ctx, *, text=None, messages):
em = discord.Embed(description=messages.embeds[0].description + "\n" + text + "\n")
messages1 = await bot.get_channel(835219679966396436).send(embed=em)
await ctx.send(messages1)
typo
@modest cloud Hello
remove the .send(embed=em))
await messages1.send(content=None, embed=em)
You accidently typed conent instead of content
yea it was a typo 😅 thanks
haha, its ok
does anyone know what this error means?
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'VoiceChannel' object has no attribute 'disconnect'
Hey @spare agate!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
you are using discordUtils?
ok let me take a screenshot of the code
yes
wrong place dude 
write
pip install PyNaCl
``` @spare agate
LOL Ok
i already have pynacl installed
but im not using
then write
pip install DiscordUtlis[voice]
ok thks
I tried it and a few other things and it didn't work
I already installed and still have this error
send me your code
did u use
try and except statements?
The whole thing?
no
let me look at your code, wait
ok
# Commands
@bot.command(name='n')
async def n(ctx, *, text=None, messages):
em = discord.Embed(description=messages.embeds[0].description + "\n" + text + "\n")
await ctx.send(Content=None, Embed=em)
how will an argument after a argument that you told to consume rest work?
Where u have written user = hbranlr.gawr
put a try statement above it and put indentation
then at the end of the function write
except Exception as y:
print(y)
just a minute
wherre is the title of the embed?
ok
lowercase the Content to be content and the Embed to be embed
there is no title of the embed, how can it work
That's a different issue, just pointing this one out
still......
title is not required
all of the embed fields are optional
Why do i get an error.......
totally forgot that
Can u send error
probably because it's empty or something?
You don't need to put title, yes
i see
still this code dosent work wat is the prob ?
?
Its not the problem, but you should save the token in other file
whats the name of your main file?
I have a question......
no linke i am able to connect after that if i try to do $github it doesnt work
content not conent
i want to learn python where should I go
ok
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
I am making a dm only command, and i want to send it to a specific channel in a server, how do i get the channel?
where
bot.get_guild and then guild.get_channel
the embed contains a hyperlink, click it
ohhh, thanxxxx
thanks
blanket do u know why this error is happening?
i need to learn from scratch
!e
print(5500 % 8)
i am still getting that issue
Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\Hp\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "D:\pythonProject\discord bot\Ansinator.py", line 14, in on_message
if message.conent.startswith('$github'):
AttributeError: 'Message' object has no attribute 'conent'
content not conent
!e
print( % 8)
i put stillno
reload your bot
how ?
your error is saying conent
can we be friends
use ctrl C
!e
print(500 % 8)
i tried both btw
if you are on console
ok
its VoiceClient.disconnect not VoiceChannel.disconnect
i am using run
ok
!e
print(084 % 8)
@slate swan :x: Your eval job has completed with return code 1.
001 | File "<string>", line 1
002 | print(084 % 8)
003 | ^
004 | SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers
#bot-commands
still
Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\Hp\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "D:\pythonProject\discord bot\Linco-bot.py", line 14, in on_message
if message.conent.startswith('$github'):
AttributeError: 'Message' object has no attribute 'conent'
even if i reload conent or content😡
did you saved the file?
because its conent there
yea
k
umm which vc in server or seperate
can be on sv
k
code:
f"{inter.author.mention} reported {inter.target.mention} for '{inter.message.content}' using message context "
error:
in reportmessage
f"{inter.author.mention} reported {inter.target.mention} for '{inter.message.content}' using message context "
AttributeError: 'Message' object has no attribute 'mention'
why.
whwat is inter
interaction i am using dislash
it is a context menu
thats fine someone else will answer
As discord.py's Greedy is an object, not a type, I was unable to use in a Union to create Union[Literal["*"], Greedy[TextChannel]] for the channels. Is there an alternative for this, or I would need to create a custom convertor inheriting the channel convertor
how to know if a message has more than 3 mentions with each mention different or no
You can use discord.Message.mentions
For this type of detection: @ping1, @ping2, @ping3 is Message.mentions
For this: @pale turtle @pale turtle @pale turtle it would be raw_mentions
how to use sleep_until?
i need friends
So I've been away from discord.py for couple months now and just started reading up on it.
I hear that we're being forced to use slash commands?
And that the original dev of discord.py quit
And now a bunch of forks are being made
Is it even worth making discord bots anymore?
A workaround is to make it 2 separate Optional arguments
But then you would have to implement some additional logic inside the function
I stopped making bots.
From what it sounds like I have to depend on dumbasses to create forks and re learn the whole module
I have to depend on dumbasses
oh?
Good forks will be made
Idk, I'm just gunna do that anymore. Using slash commands is just stupid
How so?
It's like having the same prefix and command name
But instead u got to do the extra step and go through a gui looking for your correct one if you have like 20+ bots
Well, having the same way to invoke a command for every bot, and being able to see the commands of each one without having to remember their prefix and the name of the help command for each one is more user friendly, no?
code:
f"{inter.author.mention} reported {inter.target.mention} for '{inter.message.content}' using message context "
error:
in reportmessage
f"{inter.author.mention} reported {inter.target.mention} for '{inter.message.content}' using message context "
AttributeError: 'Message' object has no attribute 'mention'
how do i mention the person the wrote the message?
i am using dislash
They could make it at least optional
that's why nowadays bots send their prefix when pinged
so you don't have to remember it
Or have it in their status
Well not all bots do
I can't implement it on all the bots, can I?
anyone?
Yeah, if the bot is ping respond with prefix
I'm not saying the current way slash commands are is the best. I'm just saying that the idea behind a unified interface is good
but making slash commands a must is not good at all
That we don't disagree
And they won't be for bots in less than 75 guilds
anyone?
many bots are weird to be played with slash commands, especially games bot, economy bot, etc
Yeah I agree
inter.target.author.mention maybe
lemme try
OMG TYSM i have been trying for so long XD
how can i execute a specific thing every 10 minutes or smth? (To change the bot status)
you can use the tasks extension
how does it work?
thx
you register a coroutine with the provided decorator, and you start the task wherever you need it to
how do you make a bot make a channel with discord.py
Guys why is this not working?
botdcID = await client.fetch_user(my bots id)
if (f"{botdcID.mention}") in message.content:
await message.channel.send("At your Service!")
anyone care about build AI Bot
I quit too
Also slash commands are not that bad.. They are but not much really. It's just discord kinda forcing us to move onto them and not listening to feedbacks, it's not fun anymore to make bots atleast for me.
Anyone?
hey.
how can we send a txt file through a webhook?
via requests.
you could learn another language and make discord bots with that language
Yeah same here. If I would still make bots they will be silent and only do moderation without commands
Learning a whole other language just for discord. Lol I like discord but not that much
yea true
That's a really bad way to check if the bot is mentioned in a message
Instead, use this: if ctx.me.mention in message.content :
or thats deprecated, idk.
Code in binary haha
if_mentionned you mean?
oh
!d discord.ClientUser.mentioned_in
mentioned_in(message)```
Checks if the user is mentioned in the specified message.
^
Yeah that's also a good option
I am using on_message event
why is this happening?
it should send a message saying that the command doesnt exists
Then use message.guild.me.mention instead of ctx.me.mention
i see
Thanku it worked
?
async def on_command_error(ctx, error)```
oh
also the error has nothing to do with the event
ok thks
const auth = require('./tokens.json')
const Discord = require('discord.js')
for (const token of auth.Tokens) {
const client = new Discord.Client()
client.on('ready', () => {
console.log('I am ready !')
console.log(client.user.id)
})
client.login(token)
}
how do i write this in python ? (js code for running many discord bots using for loop)
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix = "a prefix", kwargs...)
@bot.event
async def on_ready():
print("I am ready")
@shell lion
i want to run many discord bots without hardcoding it
Hello everyone 🙂 Im completely new to python and have a little experience coding in general. I want to make a discord bot that can fulfil a certain task, nothing TOO crazy. I followed a tutorial and set something up that can listen fora command and give an answer, though i need it to do something else aswell. If anyone would be so nice to help me walk through it `?
Basically i need my bot to listen for "$training swordfighting" and then award 1 experience point to a stat assigned to that player (say swordfighting). But this needs to be limited to X times per day/hour. How can i do smth like that ?
@bot.command()
async def chat(ctx, *, chat_text):
chatbot = ChatBot('sped')
trainer = ChatterBotCorpusTrainer(chatbot)
trainer.train("chatterbot.corpus.english")
result = chatbot.get_response(chat_text)
await ctx.send(result)``` why doesn't it work
i am trying to make a chat bot
Is it true discord.py is shutting down?
Is there anyone that could walk me through how to make my Bot do what i wanted ?
My guess, pip is not recognised as an internal or external command?
i know its not in the subject but,
how can i send a .txt file through a webhook via the requests module?
it really depends which one I do
anyone ^
discord clearly isnt a module ig
discord is a module..?
@slate swan make sure u have python set to paths
even discord.ext.commands is also
i prolly havent done that lol
Any error or issue?
check pins.
ill screenshot
Alr
Lol u have a syntax error
It's SyntaxError
I recommend you to learn python before making a discord bot
^
no no but the code is 100% correct there no way
Post it here
it was working about 4 years ago
discord.py or any other lib is not meant for complete beginners.
Wtf
It prob isn’t working now

Python updates
Because you just watched a tutorial from a channel named lucas?
im trolling with you guys 
._.
schmucks
Well, we can't help you with this. You need to learn basic python
i was joking lol
This isn't a place to joke or troll anyone
is this like srs shit lol
Well that’s just kinda annoying ngl
sometimes
@client.event
async def on_message(message):
if message.content == "tchannel":
channel = await message.guild.create_text_channel("new channel")
does anybody know how to spam creat channels with this code
im trying to test my servers moderation for nukes and trolls
i can only invite it to my servers tho
round it up in a while loop
or for
ok
how tho
im new to python give me a break😭
i am tho im just really new
ok i will
Ignoring exception in on_message
Traceback (most recent call last):
File "/home/container/.local/lib/python3.9/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "/home/container/bot.py", line 49, in on_message
cursor = await bot.db.execute("INSERT OR IGNORE INTO guildData (guild_id, user_id, exp) VALUES (?,?,?)", (message.guild.id, message.author.id, 1))
AttributeError: 'Bot' object has no attribute 'db'

wil discord.py be discont.
Do I have to Import DB or what should I do?

look at the pins messages
bot.db
you didn't define that yet
Where should I put that? Near bot = commands.Bot right?
yes
Traceback (most recent call last):
File "/home/container/bot.py", line 14, in <module>
bot.db
AttributeError: 'Bot' object has no attribute 'db'
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
The Bot object as no db attribute
How to fix this?
One message removed from a suspended account.
Ignoring exception in on_message
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/home/runner/chad-the-discord-bot/cogs/fun.py", line 434, in act
await webhook.send(
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/webhook.py", line 266, in handle_execution_response
data = await response
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/webhook.py", line 242, in request
raise HTTPException(r, data)
discord.errors.HTTPException: 429 Too Many Requests (error code: 0): {"content":"ole ole","tts":false,"avatar_url":"https://cdn.discordapp.com/avatars/464462770226724875/2fd042ff14fb4f7625fbae2f39134880.webp?size=1024","username":"mastermoneymakerman"}
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "bot.py", line 100, in on_message
await bot.process_commands(message=message)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 976, in process_commands
await self.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 943, in invoke
await ctx.command.dispatch_error(ctx, exc)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 422, in dispatch_error
await injected(cog, ctx, error)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 71, in wrapped
ret = await coro(*args, **kwargs)
File "/home/runner/chad-the-discord-bot/cogs/fun.py", line 1292, in act_error
raise (error)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 429 Too Many Requests (error code: 0): {"content":"ole ole","tts":false,"avatar_url":"https://cdn.discordapp.com/avatars/464462770226724875/2fd042ff14fb4f7625fbae2f39134880.webp?size=1024","username":"mastermoneymakerman"}```
!e py class Bot: ... bot = Bot() bot.db
@lament mesa :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 3, in <module>
003 | AttributeError: 'Bot' object has no attribute 'db'
!e py class Bot: ... bot = Bot() bot.db = "something" print(bot.db)
@lament mesa :white_check_mark: Your eval job has completed with return code 0.
something
help me
..
class Bot:
bot = Bot()
bot.db = "something"
print(bot.db)
Bot is not found, so I guess make It bot=bot()?
That was just an example.
ah ok
How can I create a bot that plays the music, like the old groovy? I was using this code, but didn't worked
async def play(self, ctx, url):
ctx.voice_client.stop()
FFMPEG_OPTIONS = {'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'options': '-vn'}
YD_OPTIONS = {'format': 'bestaudio'}
vc = ctx.voice_client
with youtube_dl.YoutubeDL(YD_OPTIONS) as ydl:
info = ydl.extract_info(url, download = False)
url2 = info['formats'][0]['url']
source = await discord.FFmpegOpusAudio.from_probe(url2,
**FFMPEG_OPTIONS)
vc.play(source)
ctx.send(f"Tocando {source}")```
!ytdl
Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders as their usage violates YouTube's Terms of Service.
For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:
The following restrictions apply to your use of the Service. You are not allowed to:
1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service; (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;
3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;
9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
its for my personal server
are u able to add multiple on_message events? if not is there a way to add more words to trigger the response on the same on_message event?
maybe you can create a list
and use this list as the trigger, im not sure
yeah you can add more words
Can anyone help?
so how would i add more to this? adding a , then another word wont work ```py
@client.event
async def on_message(message):
if message.author.bot:
return
llll = random.randint(1,10)
if 'modded' in message.content.lower():
llll = random.randint(1,10)
if llll == 8:
await message.channel.send('This is the 2019 modded war modpack')
else:
pass
await client.process_commands(message)```
Hey @glacial mesa! I noticed you posted a seemingly valid Discord API token in your message and have removed your message. This means that your token has been compromised. Please change your token immediately at: https://discordapp.com/developers/applications/me
Feel free to re-post it with the token removed. If you believe this was a mistake, please let us know!
Hey @glacial mesa! I noticed you posted a seemingly valid Discord API token in your message and have removed your message. This means that your token has been compromised. Please change your token immediately at: https://discordapp.com/developers/applications/me
Feel free to re-post it with the token removed. If you believe this was a mistake, please let us know!
@client.event
async def on_message(message):
if message.author.bot:
return
if 'modded' in message.content.lower():
llll = random.randint(1,10)
if llll == 8:
await message.channel.send('This is the 2019 modded war modpack')
elif "x" in message.content.lower():
# do something
await client.process_commands(message)
regenerated
am i able to create as many elif statements as i want then?
yeah
tyyyy
https://paste.pythondiscord.com/opozipibub.py
Ignoring exception in on_message
Traceback (most recent call last):
File "/home/container/.local/lib/python3.9/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "/home/container/bot.py", line 49, in on_message
cursor = await bot.db.execute("INSERT OR IGNORE INTO guildData (guild_id, user_id, exp) VALUES (?,?,?)", (message.guild.id, message.author.id, 1))
AttributeError: 'Bot' object has no attribute 'db'
Please english 😄
<@&831776746206265384> he's selling some shady stuff ova here
Is he? Wow
!mute 709294101454913598 Investigating
:incoming_envelope: :ok_hand: applied mute to @vestal maple until <t:1630428776:f> (59 minutes and 58 seconds).
How some people sell scams are really worrying lol
!ban @vestal maple selling illegal tools
:incoming_envelope: :ok_hand: applied ban to @vestal maple permanently.
is it best to dm modmail instead of pinging mods role?
Either is fine. If it's something that requires immediate attention, and is self-explanatory, then a ping is perfectly fine.
Adds that to where?
srry wasnt quite finished haha
Can someone...? 😄
help
hi, i want to create a bot that sees what someone types e.g $0108ben and adds 0108ben to the end of a link and that link is then posted.. but i want it to be anything they type rather than being a specific word
im not great at explaining...
what part are you stuck on
there's an on_error event where you can do error handling
not sure specifically how it works for slash commands
well... this is my code so far
import discord
client = discord.Client()
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
elif message.content.startswith('$points'):
await message.channel.send('Use this link to see peoples points in DDraceNetwork! https://ddnet.tw/ranks/ ')
i want the name to go at the end of that link.. if thats possible
discord.py doesnt support slash commands
it's a little awkward because you're not using the proper command structure
oh..
what is the correct structure? or correct command?
and you need an import
from discord.ext import commands
oo, tyvm
File "/home/pi/python/cogs/FOWbotevents.py", line 63, in on_command_error
await embed.clear_fields()
TypeError: object NoneType can't be used in 'await' expression
@commands.Cog.listener()
async def on_command_error(self, ctx, error):
embed.add_field(name = "Command Invoke Error", value = error)
await ctx.send(embed=embed)
await embed.clear_fields()
This error returns when using embed.clear_fields()
Guys I created a warn system in discord py, but I don't understand why it tells me command non-existent if I try to type! Help warn
here the code:
class Warns (commands.Cog):
def __init __ (self, bot):
self.bot = bot
@ commands.command ()
@ commands.guild_only ()
@ commands.has_role (870259242744021033)
async def warn (self, ctx, member: discord.Member, *, reason):
if member.id in [ctx.author.id, self.bot.user.id]:
return await ctx.send ("You can't warn yourself or the bot!")
current_warn_count = len (
await self.bot.warns.find_many_by_custom (
{
"user_id": member.id,
"guild_id": member.guild.id
}
)
) +1
warn_filter = {"user id": member.id, "guild_id": member.guild.id, "number": current_warn_count}
warn_data = {"reason": reason, "timestamp": ctx.message.created_at, "warned_by": ctx.author.id}
await self.bot.warns.upsert_custom (warn_filter, warn_data)
embed = discord.Embed (
title = "You have been warned:",
description = f "__ ** Reason ** __: \ n {reason}",
color = discord.Colour.red (),
timestamp = ctx.message.created_at
)
embed.set_author (name = ctx.guild.name, icon_url = ctx.guild.icon_url)
embed.set_footer (text = f "Warn: {current_warn_count}")
try:
await member.send (embed = embed)
await ctx.send ("I warned the user in the DM's")
except discord.HTPPException:
await ctx.send (member.mention, embed = embed)
def setup (bot):
bot.add_cog (Warns (bot))
what is ctx? sorry for all the questions
ctx is the contest of the bot
ah ty
np
.
The context. Contains information about the invocation of the command. Who invoked it, what channel, what time, what guild etc etc.
Can anyone tell me how to install pynacl? command pip install PyNaCl does not work
what does your terminal say
error-wise
ah, thank you :D
The term 'pip' is not recognized as the name of a cmdlet, function, script file, or operable program.
you can find all of this on the discord.py wiki
try pip3
Ignoring exception in on_message
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/home/runner/chad-the-discord-bot/cogs/fun.py", line 434, in act
await webhook.send(
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/webhook.py", line 266, in handle_execution_response
data = await response
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/webhook.py", line 242, in request
raise HTTPException(r, data)
discord.errors.HTTPException: 429 Too Many Requests (error code: 0): {"content":"ole ole","tts":false,"avatar_url":"https://cdn.discordapp.com/avatars/464462770226724875/2fd042ff14fb4f7625fbae2f39134880.webp?size=1024","username":"mastermoneymakerman"}
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "bot.py", line 100, in on_message
await bot.process_commands(message=message)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 976, in process_commands
await self.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 943, in invoke
await ctx.command.dispatch_error(ctx, exc)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 422, in dispatch_error
await injected(cog, ctx, error)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 71, in wrapped
ret = await coro(*args, **kwargs)
File "/home/runner/chad-the-discord-bot/cogs/fun.py", line 1292, in act_error
raise (error)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 429 Too Many Requests (error code: 0): {"content":"ole ole","tts":false,"avatar_url":"https://cdn.discordapp.com/avatars/464462770226724875/2fd042ff14fb4f7625fbae2f39134880.webp?size=1024","username":"mastermoneymakerman"}```
How to fix dis errorrrrrrrrrrr
same error
Guys I created a warn system in discord py, but I don't understand why it tells me command non-existent if I try to type! Help warn
here the code:
`class Warns (commands.Cog):
def init (self, bot):
self.bot = bot
@ commands.command ()
@ commands.guild_only ()
@ commands.has_role (870259242744021033)
async def warn (self, ctx, member: discord.Member, *, reason):
if member.id in [ctx.author.id, self.bot.user.id]:
return await ctx.send ("You can't warn yourself or the bot!")
current_warn_count = len (
await self.bot.warns.find_many_by_custom (
{
"user_id": member.id,
"guild_id": member.guild.id
}
)
) +1
warn_filter = {"user id": member.id, "guild_id": member.guild.id, "number": current_warn_count}
warn_data = {"reason": reason, "timestamp": ctx.message.created_at, "warned_by": ctx.author.id}
await self.bot.warns.upsert_custom (warn_filter, warn_data)
embed = discord.Embed (
title = "You have been warned:",
description = f " Reason : \ n {reason}",
color = discord.Colour.red (),
timestamp = ctx.message.created_at
)
embed.set_author (name = ctx.guild.name, icon_url = ctx.guild.icon_url)
embed.set_footer (text = f "Warn: {current_warn_count}")
try:
await member.send (embed = embed)
await ctx.send ("I warned the user in the DM's")
except discord.HTPPException:
await ctx.send (member.mention, embed = embed)
def setup (bot):
bot.add_cog (Warns (bot))`
stop sending the same question and format it properly
Looks like you're being rate limited
HTTPException: 429 Too Many Requests
so suppose i hv http exception... How can i show tht i am
is it cuz repl.it?
yes
dang
replit is bad
reinstall python and add pip to your python PATH
code:
from discord.ext.commands import bot
client = discord.Client()
@bot.command()
async def ping(ctx):
await ctx.send(f"Pong! {round(bot.latency * 1000)}ms")
error:
line 6, in <module>
@bot.command()
AttributeError: module 'discord.ext.commands.bot' has no attribute 'command'
why?
should be like a checkbox in the installer
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
@river kindle ^
Format like above please
?
@river kindle
It's because you're using client, rather than bot. I would use bot if I was you
@client.command()
async def about(ctx):
embed = discord.Embed(title ='About BeastyCards',description=f"```Command prefix = Yo```\n**Description:**\n {ctx.message.author.name} blo,\n:replywline: Beastycards is a turn based Battle Royale game where you start \n:replywline: with a selected starter weapon, duel other fights in the server to\n:replywline:gain coins that allow you to buy new and better items and level \n:replywline:as you win more fights\n:replywline:Now you can go Fishing, Mining and Hunting also Search in stuff\n:replybc:by picking a location to gain coins and sometimes items!",timestamp=ctx.message.created_at).set_thumbnail(url="https://cdn.discordapp. com/attachments/871682344229167114/879760788825440256/image_2021-08-24_214235-removebg-preview.png")
embed.set_footer(text="yo help to see more details ")
await ctx.reply(embed=embed)```
done
Is there an error?
Nop
are you sure the function is being called?
wha? sorry ive only just started using this bot stuffs since like an hour ago lol so i have no idea what any of this means
Guys I created a warn system in discord py, but I don't understand why it tells me command non-existent if I try to type! Help warn
here the code:
class Warns (commands.Cog):
def init (self, bot):
self.bot = bot
@ commands.command ()
@ commands.guild_only ()
@ commands.has_role (870259242744021033)
async def warn (self, ctx, member: discord.Member, *, reason):
if member.id in [ctx.author.id, self.bot.user.id]:
return await ctx.send ("You can't warn yourself or the bot!")
current_warn_count = len (
await self.bot.warns.find_many_by_custom (
{
"user_id": member.id,
"guild_id": member.guild.id
}
)
) +1
warn_filter = {"user id": member.id, "guild_id": member.guild.id, "number": current_warn_count}
warn_data = {"reason": reason, "timestamp": ctx.message.created_at, "warned_by": ctx.author.id}
await self.bot.warns.upsert_custom (warn_filter, warn_data)
embed = discord.Embed (
title = "You have been warned:",
description = f " Reason : \ n {reason}",
color = discord.Colour.red (),
timestamp = ctx.message.created_at
)
embed.set_author (name = ctx.guild.name, icon_url = ctx.guild.icon_url)
embed.set_footer (text = f "Warn: {current_warn_count}")
try:
await member.send (embed = embed)
await ctx.send ("I warned the user in the DM's")
except discord.HTPPException:
await ctx.send (member.mention, embed = embed)
def setup (bot):
bot.add_cog (Warns (bot))
Yeaa
import discord
import discord.ext.commands
bot = discord.Bot()
...
you didn't define bot previously
OHH, thank you
I did
Should be commands.bot(command_prefix="!")
Add from discord.ext import commands
Edit nvm i am dum 
Apps and Features > Python > Modify > select pip > select Add Python to environment variables
it doesnt recognise Bot D:
:)
what does the error actually say
bot = discord.Bot()
AttributeError: module 'discord' has no attribute 'Bot'```
@heavy belfry
bot = commands.Bot(command_prefix = "i
!")
Try this
There is no discord.Bot, it's only discord.Client which you shouldn't use, It's discord.ext.commands.Bot
yuppp, this seems to have worked, thanks
I did
Np
U did not assigned a prefix to it
Bot *
async def ping(ctx):
await ctx.send(f"Pong! {round(bot.latency * 1000)}ms")
so how do i get this to work?
Guys, i want to store the number of messages by the users in a json file, anybody can help me?
Just write $ping
nothing happens D:
error?
show me where u have defined the prefix
Whats you prefix
nope
command_prefix="$"
show the code
from discord.ext.commands import bot
from discord.ext import commands
import discord.ext
client = discord.Client()
bot = commands.Bot(command_prefix="$")
@bot.command()
async def ping(ctx):
await ctx.send(f"Pong! {round(bot.latency * 1000)}ms")```
enable intents
how?
ah i see, ty :D
Whats client = discord.Client()
wait
not reallysure....
REMOVE IT
o
gone
client = commands.Bot(command_prefix="!",help_command=None, intents=discord.Intents.all())
``` After enabling intents, add this
@heavy belfry
why would you add something you dont know to your code
okay
Delete client and bot from this code and paste what i have given
and use your prefix instead of !
Pls add 3 not 2 its hard to see code in 2
without bot it will not connetct to my discord tho
wth do u mean?
look, i have not got a single idea what im doing..
use what i have given u, delete both bot and client from your orginial code
Yhe follow some vedios first and understand
try it
very good spellings of video
Naming it bot would be better and consistent with naming convention
Its their choice, i cant really change it now, I have like 1000+ lines of code in the file
Also help_command=None?
You don't need help command?
Oh yeah
Yhe bot is better my bot have client and get hard on me sometime i type bot and try to run the code
@slate swanCan u help me a bit too?
maybe they have their own one?
discord automatically makes a help command, which is pretty annoying if u forget to disable it
from discord.ext.commands import bot
from discord.ext import commands
import discord.ext
client = commands.Bot(command_prefix="!",help_command=None, intents=discord.Intents.all())
@bot.command()
async def ping(ctx):
await ctx.send(f"Pong! {round(bot.latency * 1000)}ms")
line 9, in <module>
@bot.command()
AttributeError: module 'discord.ext.commands.bot' has no attribute 'command'
commands.Bot is better, yes. But the naming you call them by client.bot = ..., it's preferred to have bot with commands.Bot and client with discord.Client
name the client variable, bot
Then it's not a good way to make a custom help command
and use your own prefix
Yhe
setting help_command to none disables the default help command to make way for your own one so yes it is a good way to start making a custom help command, depending on the way you make it
i want to store the number of messages sent by each user in a json file, anybody can help me?
from discord.ext.commands import
bot-> bot is a module not the bot object
remove unused imports, likeimport discord.ext,from discord.ext.commands import botandimport discord
it's better to name itbotinstead ofclient
in your decorator@bot.command, it's the class instance with which bot is linked. So name it whatever you named your instance.
What is pymache.py
It works but not a very good way for several reasons, and limit the flexibility of your help command.
https://gist.github.com/InterStella0/b78488fb28cadf279dfd3164b9f0cf96 have a look at this for whole walkthrough




