#discord-bots

1 messages · Page 436 of 1

slate swan
#

commands.CommandInvokeError*

maiden fable
#

Huh?

maiden fable
slate swan
maiden fable
#

What's that?

slate swan
#

One out of 3k forks

maiden fable
#

whose

slate swan
#

One of my friends'

maiden fable
#

Ah ok

slate swan
#

They created a support bot and a 29 level boosted "support" server without implementing anything in fork

maiden fable
vale wing
#

@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

maiden fable
#

Cz it won't be handled

#

U never added anything to it

vale wing
#

Very weird

vale wing
maiden fable
#

if isinstance(error, discord.Forbidden):
# do something

slate swan
#

NotFound* in their case

vale wing
cloud dawn
#

inside the command a bare try/except always works to stop showing the error

vale wing
#

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

slate swan
#

How can I make a bot? And a website together?

#

Like implementing your bot inside the website or reverse?

cloud dawn
slate swan
#

Ye

slate swan
#

Like in 1 file my bot and website

cloud dawn
#

Those are 2 questions pithink

slate swan
#

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?

cloud dawn
#

I used subprocess, quart, quart-discord and discord-ext-ipc to do this.

slate swan
#

Also it's better to have them separately and implement API into your site to communicate with your bot

slate swan
#

Yes

#

Idk what I'm saying, ignore me notlikeduck

#

Do django supports async IPC? ASGI, nvm

clever pelican
#

mnullu Hey

#

Can someone help please, I have installed DiscordUtils but

import DiscordUtils```
Doesn't work
#

I got an error

south kayak
#

Ok

#

im trying to make cogs from start

#

but i'm having this error

high flame
south kayak
clever pelican
south kayak
clever pelican
#

Discord theme (dark)

high flame
#

uhm

south kayak
clever pelican
clever pelican
vale narwhal
vale narwhal
clever pelican
#

I mean

vale narwhal
#

Cannot find module?

clever pelican
#

Yes

vale narwhal
#

can you give me the ss/text of the error

clever pelican
#

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

vale narwhal
#

uh

#

So what now

clever pelican
#

¯_(ツ)_/¯

vale narwhal
#

And run the command

#

Then check if there's any error

south kayak
#

hello

#

I need help with cogs

clever pelican
vale narwhal
#

Wasn't it "cogs"

clever pelican
#

Works now!

#

Thank you

vale narwhal
#

Alr

south kayak
vale narwhal
#

Can you try use pip uninstall cogs

south kayak
#

I have this:

for filename in os.listdir('./cogs'):
    if filename.endswith('.py'):
      client.load_extension(f'cogs.{filename[-3]}')
vale narwhal
#

Then clear your local caches

agile goblet
#

a module is also a folder with python files

south kayak
agile goblet
#

show your tree

vale narwhal
#

coding on a cloud is worsts idea

clever pelican
#
for filename in os.listdir('cogs',):
    if filename.endswith('.py'):
        client.load_extension(f'cogs.{filename[:-3]}')```
Try this
#

works for me

#

¯_(ツ)_/¯

vale narwhal
#

ಠ_ಠ

clever pelican
#

ಠ_ಠ

vale narwhal
#

/╲/\╭(•‿•)╮/\╱\

clever pelican
#

cool emoji

vale narwhal
#

wtf

clever pelican
#

?

slate swan
vale narwhal
#

nothing

clever pelican
south kayak
clever pelican
#

Show

vale narwhal
#

Show

clever pelican
south kayak
#

Extension 'cogs.participate' has no 'setup' function.

vale narwhal
#

cogs sometimes it is confused

cloud dawn
clever pelican
#

Did you added the

def setup(client):
    client.add_cog(someting(client))```
south kayak
#

so?

#

whats someting?

vale narwhal
#

something

cloud dawn
clever pelican
#

Yes

south kayak
#

😩

#

do I have to put this for every command?

clever pelican
#

Indeed

cloud dawn
clever pelican
#

Oh right

cloud dawn
#

Don't spread misinformation.

clever pelican
#

srry

vale narwhal
#

Why shitpost here

south kayak
#

do i shitpost?

#

😫

maiden fable
#

@south kayak pls delete the GIF(s) from here. This isn't the correct place to do so

#

Thanks

south kayak
#

ok ok

vale narwhal
#

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)
vale narwhal
#

I want it to be like that

#

Ignore it

cloud dawn
#

What variable is ez?

vale narwhal
#

Basically it's error generator some cringy command that i was doing

#

Is it correct to use "if" like that?

cloud dawn
#

But you are also comparing a tuple to a string.

vale narwhal
#

Just asking only the "if" part-

slate swan
#

yo i tried hosting my bot on heroku but it aint working

vale narwhal
#

Lemme try run it ig

slate swan
#

it shows "no bot token found"

cloud dawn
slate swan
vale narwhal
slate swan
vale narwhal
#

oops

#

Forgot it was python

#

lmao

slate swan
#

😂

#

but listen, in pycharm my bot works and runs

vale narwhal
slate swan
#

but in heroku or zeplit it doesnt work

slate swan
vale narwhal
#

I was also hosting on heroku

#

It was working fine

slate swan
#

oh this is my error

vale narwhal
#

show it when

clever pelican
#
'Music' object has no attribute 'create'```
Sorry but what doest it mean?
#

I dont' understand

slate swan
clever pelican
#
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

vale narwhal
#

lemme read

clever pelican
#

Ok srry

vale narwhal
#

when you start it run only main one

#

But if you run command it run the command code

clever pelican
#

yes

serene lynx
#
@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?

vale narwhal
#

and what is it

slate swan
#

thats my error

#

in heroku

vale narwhal
#

Uh

#

Use heroku CLI

slate swan
#

in the logs i mean

vale narwhal
#

And remote it from your cmd prompt

#

then do

#

heroku logs --tail

clever pelican
slate swan
#

ill try that

vale narwhal
#

Idk

#

I'm not similar to music bot

#

Let other people handle it

clever pelican
#

ok

clever pelican
slate swan
#

cuzzz i mayyy need more help

vale narwhal
#

Ah

slate swan
#

yep yep yep

vale narwhal
#

@slate swan do you have the "Procfile"

slate swan
#

yea i do

#

it all cool

#

i have proc, req and all

vale narwhal
#

Did you disable the default dyno one

slate swan
#

there wasny a default dyno

vale narwhal
#

If no then do it

slate swan
#

it was empy

vale narwhal
#

Lemme show you

slate swan
#

oh okay

#

and thank you

vale narwhal
#

The top one is the default

#

But when you put procfile

#

The bottom one will appear

#

Also

slate swan
vale narwhal
slate swan
#

yea it is

#

i changed main to run

vale narwhal
#

Can you try delete the token in config.py and put it straight in the main one instead

slate swan
#

it is in the main one

vale narwhal
#

<yoursomething>.run('<token>')

slate swan
#

i know

clever pelican
slate swan
#

client.run('token')

slate swan
#

ohh fuk i used to have that error too

vale narwhal
slate swan
#

get_player aint found

slate swan
vale narwhal
#

Download git

slate swan
#

i have it

vale narwhal
#

Do you have git on your pc?

slate swan
#

i do

#

desktop

vale narwhal
#

Alr open git bash on the folder that you have your bot files in

#

then do this

clever pelican
vale narwhal
#

heroku login

slate swan
slate swan
#

fo real

clever pelican
#

get_player always worked for me

#

But not now

slate swan
#

well i think for me it wass cuzz i didnt import something

vale narwhal
#

heroku login
heroku git:remote <your_app_name>
heroku logs --tail

#

Do this and send me the error/text

clever pelican
molten oar
#
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)```
slate swan
#

its stuck here

molten oar
vale narwhal
#

Wait for it ig?

slate swan
vale narwhal
molten oar
slate swan
#

done now what if i may ask

vale narwhal
#

yes?

slate swan
clever pelican
#

And i found... || nothing ||

vale narwhal
#

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

eager bolt
#

is there anyone who can help me with something?

slate swan
#

i got that error

vale narwhal
#

Did you uh

molten oar
vale narwhal
#

do the git remote one

clever pelican
slate swan
#

the command

vale narwhal
#

heroku git:remote -a (your app name here)

molten oar
slate swan
vale narwhal
slate swan
#

ohkay

eager bolt
#

can anyone help me with something how do i disable using commands in dms?

south kayak
#

I managed to get the load_extension work but: discord.ext.commands.errors.CommandNotFound: Command "register" is not found

vale narwhal
vale narwhal
#

whoops

slate swan
vale narwhal
#

lemme check again hold on

eager bolt
vale narwhal
#

Copy and paste this

#

heroku git:remote -a (yourappname)

#

put your app name at the back section

south kayak
vale narwhal
#

Lemme check first

vale narwhal
eager bolt
vale narwhal
#

put it below the client.command()

slate swan
#

ahh leave it but thank you for your help

vale narwhal
slate swan
vale narwhal
#

@eager bolt

@something.command()
@commands.guild_only()
async def steam(ctx):
      //your code
#

Replace something with bot or client or something that you used

slate swan
#

how to kick someone from a vc?

#

u made mee6?

slate swan
#

dayum

#

how do i kick somebody from a vc?

#

@unkempt canyon

#

prefix?

#

!discord.VoiceText

#

i meant

pale turtle
#

The prefix is !

slate swan
#

!discord.VoiceChannel

#

oh

pale turtle
unkempt canyonBOT
#

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.
pale turtle
#

!d discord.Member.edit

unkempt canyonBOT
#

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...
pale turtle
#

You can do edit(voice_channel=None)

slate swan
vale narwhal
#

Like this

await member_to_kick.edit(voice_channel=None)
vale narwhal
#

replace "member_to_kick" to yours

slate swan
minor kestrel
#

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:

slate swan
#
sqlite3.OperationalError: database is locked

What it's mean

minor kestrel
upbeat otter
#

Guys, is there any way, i take input from the user from a dm and send it in a specific channel in a server

slate swan
#

What is the event called when a new member joins the server?

upbeat otter
dapper cobalt
unkempt canyonBOT
#

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.
slate swan
#

thanks

slate swan
#

!d discord.ext.commands.Bot.wait_for

unkempt canyonBOT
#

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**...
upbeat otter
#

.....

dapper cobalt
slate swan
#

@upbeat otter ^ wait for a message from the dm of user

#

or dms only command, yes

upbeat otter
mint sundial
#

i need someone to learn me how to create a discord bots by python

unkempt canyonBOT
upbeat otter
slate swan
#

bhaiya*? umm

mint sundial
upbeat otter
upbeat otter
slate swan
slate swan
slate swan
mint sundial
hasty iron
#

then continue learning

#

and don't jump in discord.py since it's a hard lib for beginners

slate swan
#

^ You must know more then ig

mint sundial
#

oop no i dont have any info about

mint sundial
#

ig ?

slate swan
mint sundial
#

k

#

any one here speak arabic ?

floral marlin
#

no

#

i speak spanish

minor kestrel
#

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:

slate swan
#

!d discord.Member.activity

unkempt canyonBOT
#

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").
stark bobcat
#

Hello

maiden fable
#

Huh

#

Weird

#

!d discord.Member.activities

unkempt canyonBOT
#

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.

maiden fable
#

There

minor kestrel
maiden fable
#

And yea, that ain't a random number, definitely not

visual island
hasty iron
#

some people prefer light mode

visual island
#

it's brighter than the sun

stark bobcat
#

Light mode not that bad

hasty iron
#

you can't force them to switch just because you dont like it

floral marlin
#

Can I make my discord bot appear connected from cell phone?

maiden fable
visual island
stark bobcat
#

I use light mode for replit woah

maiden fable
unkempt canyonBOT
#

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!

floral marlin
maiden fable
#

Light mode

hasty iron
#

lmao

hasty iron
maiden fable
maiden fable
floral marlin
#

and i needs install ;/?

hasty iron
#

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

minor kestrel
#

How can I know if the activity of a user is in the Streaming Category?? To get the streaming url and those things

floral marlin
slate swan
maiden fable
#

Yea

unkempt canyonBOT
#

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.

maiden fable
#

They return the list of activities

#

Use a loop and check each element with isinstance()

valid patio
#

why did i get ?

peak kernel
#

Your var is none

hasty iron
#

the token you passed in is None

#

getenv returned None

maiden fable
visual island
slate swan
#

!pypi python_dotenv

unkempt canyonBOT
floral marlin
#

@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?

visual island
#

!code

unkempt canyonBOT
#

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.

fair axle
#

i am making a /report command and i want to send the report to the #reports channel

slate swan
#

To get updated, make a task

maiden fable
#

Why not set the status in a task and start it...? That way, u will set the status as well as update it

maiden fable
#

!d discord.ext.tasks.Loop

unkempt canyonBOT
#

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").
maiden fable
#

!d discord.Guild.get_channel

unkempt canyonBOT
maiden fable
#

!d discord.TextChannel.send

unkempt canyonBOT
#

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.
fair axle
#

it is a slash command

#
    await inter.reply(embed=sus, ephemeral=True)
#

how do i put the channel in there lol

glacial mesa
little ether
#

dislash?

fair axle
maiden fable
#

Ah

fair axle
#

yes

maiden fable
#

Well, it's easy

#

await channel.send()

dapper cobalt
maiden fable
#

channel = inter.guild.get()

little ether
#

^ what Hunter said

dapper cobalt
#

Or channel = inter.channel?

maiden fable
#

No

dapper cobalt
#

Wait that's hunter, nevermind.

fair axle
#

i want to send to specific channel

maiden fable
#

He wants to send the report in a specific channel

fair axle
#

yeah

dapper cobalt
floral marlin
#

get chanell id and send message there

#

:)

slate swan
#

@fair axle interaction?

slate swan
fair axle
slate swan
fair axle
slate swan
fair axle
slate swan
#

Got it

floral marlin
#

@Client.command()
async def resports(ctx, arg):
channelid = "your channel id of reports"
await channelid.send(arg)

fair axle
#

:)

slate swan
floral marlin
#

you needs add content

slate swan
#

!d discord.Guild.get_channel

unkempt canyonBOT
floral marlin
slate swan
#

...

humble sparrow
#

bot says ffmpeg not found when i try to play music :( welp

fair axle
#

like this?

channel = inter.guild.get_channel(ID)
    await channel.send(f"i am big brain")
slate swan
#

Yes

hasty iron
fair axle
#

ok lemme try

#

it worked!
thanks to everyone that helped :D

slate swan
#

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.

slate swan
#

wait answer...

maiden fable
#

!d discord.Member.ban

unkempt canyonBOT
#

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").
maiden fable
#

!d discord.Member.kick

unkempt canyonBOT
#

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").
maiden fable
#

!d discord.Member.add_roles

unkempt canyonBOT
#

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.
maiden fable
#

!d discord.Member.remove_roles

slate swan
#

Thank you!

unkempt canyonBOT
#

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.
minor kestrel
maiden fable
#

!d discord.Streaming

unkempt canyonBOT
#

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.
valid patio
#

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'

valid patio
#

???????????????????????????????????????????????????????//

upbeat otter
#

there is nothing as conent

#

its content

surreal sierra
#

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)
upbeat otter
#

typo

hexed heath
#

@modest cloud Hello

upbeat otter
plucky shoal
valid patio
upbeat otter
spare agate
#

does anyone know what this error means?

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'VoiceChannel' object has no attribute 'disconnect'

unkempt canyonBOT
upbeat otter
#

you are using discordUtils?

spare agate
#

ok let me take a screenshot of the code

spare agate
upbeat otter
#

and write

spare agate
upbeat otter
#
pip install DiscordUtils[voice]
#

after that is done

modest cloud
upbeat otter
#

write

pip install PyNaCl
``` @spare agate
hexed heath
spare agate
#

but im not using

upbeat otter
spare agate
#

ok thks

surreal sierra
spare agate
upbeat otter
upbeat otter
surreal sierra
upbeat otter
#

Of the code

spare agate
upbeat otter
spare agate
#

ok

surreal sierra
# upbeat otter i mean the part
# 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)
spring flax
upbeat otter
# spare agate ok

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)

upbeat otter
#

wherre is the title of the embed?

plucky shoal
upbeat otter
plucky shoal
upbeat otter
hasty iron
#

all of the embed fields are optional

upbeat otter
surreal sierra
stark bobcat
#

Can u send error

slate swan
spare agate
valid patio
#

still this code dosent work wat is the prob ?

spare agate
#

its when I use the command leave

#

join is working

spare agate
#

whats the name of your main file?

upbeat otter
#

I have a question......

valid patio
#

no linke i am able to connect after that if i try to do $github it doesnt work

hasty iron
mint summit
#

i want to learn python where should I go

valid patio
hasty iron
unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

upbeat otter
#

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?

mint summit
hasty iron
hasty iron
upbeat otter
mint summit
#

thanks

spare agate
mint summit
#

i need to learn from scratch

slate swan
#

!e
print(5500 % 8)

valid patio
#

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'

hasty iron
#

content not conent

slate swan
#

!e
print( % 8)

valid patio
slate swan
#

i need friends

#

!e
print(5500 % 8)

hasty iron
valid patio
#

how ?

spare agate
slate swan
spare agate
slate swan
#

!e
print(500 % 8)

valid patio
spare agate
#

if you are on console

valid patio
hasty iron
valid patio
spare agate
#

and use content now

valid patio
#

ok

slate swan
#

!e
print(084 % 8)

unkempt canyonBOT
#

@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
hasty iron
valid patio
#

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😡

spare agate
#

because its conent there

valid patio
spare agate
#

can you join a vc and show your screen?

#

and do not show your token pls

valid patio
valid patio
spare agate
#

can be on sv

valid patio
spare agate
#

show your screen pls @valid patio

#

oh

fair axle
#

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.

fair axle
spring flax
#

is that a command?

#

show the full thing

fair axle
#

it is a context menu

spring flax
#

uh never used that before

#

but what's the full code

fair axle
#

thats fine someone else will answer

deep musk
#

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

silent hawk
#

how to know if a message has more than 3 mentions with each mention different or no

pale turtle
#

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

faint rock
#

how to use sleep_until?

slate swan
#

i need friends

south walrus
#

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?

rough ledge
south walrus
vocal plover
#

I have to depend on dumbasses
oh?

south walrus
vocal plover
#

How so?

south walrus
#

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

zinc reef
#

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?

fair axle
#

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

south walrus
visual island
#

so you don't have to remember it

south walrus
#

Or have it in their status

zinc reef
#

Well not all bots do

visual island
#

implement that then

zinc reef
#

I can't implement it on all the bots, can I?

south walrus
zinc reef
#

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

visual island
#

but making slash commands a must is not good at all

zinc reef
#

That we don't disagree

south walrus
#

Lol

#

Clearly we're disagreeing

zinc reef
#

And they won't be for bots in less than 75 guilds

visual island
#

many bots are weird to be played with slash commands, especially games bot, economy bot, etc

visual island
fair axle
#

OMG TYSM i have been trying for so long XD

dim oriole
#

how can i execute a specific thing every 10 minutes or smth? (To change the bot status)

zinc reef
#

you can use the tasks extension

dim oriole
#

how does it work?

dim oriole
#

thx

zinc reef
#

you register a coroutine with the provided decorator, and you start the task wherever you need it to

dim oriole
slate swan
#

how do you make a bot make a channel with discord.py

dim oriole
#

channel = await guild.create_text_channel('cool-channel')

upbeat otter
#

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!")
muted vessel
#

anyone care about build AI Bot

slate swan
slate swan
#

hey.
how can we send a txt file through a webhook?
via requests.

slate swan
south walrus
slate swan
#

i mean rip bots

#

it was a nice era.

south walrus
slate swan
#

yea true

south walrus
#

I mean I know c# kind of

#

I'll make a c# bot lmao

slate swan
#

i was trying to learn golang for discord but i quit

#

Yeah not worth it.

plucky shoal
slate swan
#

yes, i think theres a listener?

#

if_mentionned

plucky shoal
#

Instead, use this: if ctx.me.mention in message.content :

slate swan
#

or thats deprecated, idk.

south walrus
slate swan
#

if_mentionned you mean?

upbeat otter
#

oh

slate swan
#

!d discord.ClientUser.mentioned_in

unkempt canyonBOT
slate swan
#

^

plucky shoal
#

thisYeah that's also a good option

spare agate
upbeat otter
spare agate
#

why is this happening?

#

it should send a message saying that the command doesnt exists

plucky shoal
upbeat otter
spare agate
spring flax
spare agate
#

oh

spring flax
#

also the error has nothing to do with the event

spare agate
#

ok thks

shell lion
#
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)

spring flax
#
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

shell lion
#

i want to run many discord bots without hardcoding it

stark bobcat
hallow cave
#

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 ?

stark bobcat
#
@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

inner pumice
slate swan
#

why doesnt pip install work?

#

Check the pins

hallow cave
#

Is there anyone that could walk me through how to make my Bot do what i wanted ?

slate swan
#

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

stark bobcat
slate swan
#

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

slate swan
#

omfg

slate swan
#

Any error or issue?

#

check pins.

slate swan
#

oh and

slate swan
#

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

slate swan
#

it was working about 4 years ago

#

discord.py or any other lib is not meant for complete beginners.

slate swan
#

It prob isn’t working now

#

Python updates

#

Because you just watched a tutorial from a channel named lucas?

#

im trolling with you guys Cry

#

._.

#

schmucks

#

Well, we can't help you with this. You need to learn basic python

slate swan
#

This isn't a place to joke or troll anyone

#

is this like srs shit lol

slate swan
hasty iron
#

sometimes

slate swan
#

@client.event
async def on_message(message):
if message.content == "tchannel":
channel = await message.guild.create_text_channel("new channel")

slate swan
slate swan
stark bobcat
#

sus

slate swan
stark bobcat
#

ok

stark bobcat
#

or for

slate swan
slate swan
stark bobcat
#

learn python

slate swan
stark bobcat
#

take break then

slate swan
slate swan
stark bobcat
#

i will take snack break soon

ionic wadi
#

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'

stark bobcat
ocean escarp
ionic wadi
slate swan
slate swan
spring flax
#

you didn't define that yet

ionic wadi
spring flax
#

yes

ionic wadi
#

Traceback (most recent call last):
File "/home/container/bot.py", line 14, in <module>
bot.db
AttributeError: 'Bot' object has no attribute 'db'

novel sky
#

One message removed from a suspended account.

#

One message removed from a suspended account.

ionic wadi
#

Its only discontinuing

#

Its not vanishing or so

novel sky
lament mesa
gloomy coral
#

How to fix this?

novel sky
gloomy coral
#
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"}```
lament mesa
unkempt canyonBOT
#

@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'
lament mesa
#

!e py class Bot: ... bot = Bot() bot.db = "something" print(bot.db)

unkempt canyonBOT
#

@lament mesa :white_check_mark: Your eval job has completed with return code 0.

something
gloomy coral
#

help me

ionic wadi
lament mesa
#

That was just an example.

ionic wadi
#

ah ok

spare agate
#

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}")```
lament mesa
#

!ytdl

unkempt canyonBOT
#

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)
spare agate
#

its for my personal server

waxen tangle
#

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?

spare agate
#

and use this list as the trigger, im not sure

ionic wadi
#

Can anyone help?

waxen tangle
# full lily yeah you can add more words

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)```

unkempt canyonBOT
#

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!

full lily
#
@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)
ionic wadi
#

regenerated

glacial mesa
#

dont reapeat mistake

#

change it and then send

waxen tangle
full lily
#

yeah

waxen tangle
#

tyyyy

ionic wadi
#

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 😄

full lily
#

<@&831776746206265384> he's selling some shady stuff ova here

ionic wadi
#

Is he? Wow

visual yarrow
#

!mute 709294101454913598 Investigating

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied mute to @vestal maple until <t:1630428776:f> (59 minutes and 58 seconds).

ionic wadi
#

How some people sell scams are really worrying lol

tight obsidian
#

!ban @vestal maple selling illegal tools

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied ban to @vestal maple permanently.

full lily
#

is it best to dm modmail instead of pinging mods role?

visual yarrow
full lily
#

Adds that to where?

heavy belfry
heavy belfry
#

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...

full lily
#

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

heavy belfry
# full lily what part are you stuck on

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

ionic wadi
full lily
heavy belfry
full lily
#

and you need an import
from discord.ext import commands

heavy belfry
#

oo, tyvm

wary ravine
#
  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()

river kindle
#

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))

heavy belfry
river kindle
heavy belfry
river kindle
#

np

wary ravine
#

format your code properly

full lily
rustic perch
#

Can anyone tell me how to install pynacl? command pip install PyNaCl does not work

wary ravine
#

error-wise

rustic perch
full lily
gloomy coral
#
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

rustic perch
river kindle
#

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))`

wary ravine
full lily
full lily
gloomy coral
#

so suppose i hv http exception... How can i show tht i am

gloomy coral
full lily
#

yes

gloomy coral
#

dang

wary ravine
#

replit is bad

wary ravine
heavy belfry
#

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?

wary ravine
#

should be like a checkbox in the installer

full lily
#

!code

unkempt canyonBOT
#

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.

wary ravine
#

@river kindle ^

river kindle
wary ravine
full lily
lone flume
#
@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)```
heavy belfry
lone flume
full lily
heavy belfry
river kindle
#

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))
lone flume
wary ravine
heavy belfry
#

OHH, thank you

rustic perch
fickle turret
ionic karma
wary ravine
# rustic perch I did

Apps and Features > Python > Modify > select pip > select Add Python to environment variables

wary ravine
heavy belfry
#
    bot = discord.Bot()
AttributeError: module 'discord' has no attribute 'Bot'```
ionic karma
#

@heavy belfry

bot = commands.Bot(command_prefix = "i
!")

Try this

fickle turret
#

There is no discord.Bot, it's only discord.Client which you shouldn't use, It's discord.ext.commands.Bot

heavy belfry
ionic karma
ionic karma
#

Bot *

heavy belfry
upbeat otter
#

Guys, i want to store the number of messages by the users in a json file, anybody can help me?

heavy belfry
wary ravine
upbeat otter
heavy belfry
heavy belfry
upbeat otter
heavy belfry
# upbeat otter 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")```
heavy belfry
#

how?

upbeat otter
#

go to discord dev portal

#

go to the bot section

#

and scroll down

heavy belfry
#

ah i see, ty :D

ionic karma
upbeat otter
heavy belfry
ionic karma
heavy belfry
heavy belfry
upbeat otter
#
client = commands.Bot(command_prefix="!",help_command=None, intents=discord.Intents.all())
``` After enabling intents, add this
#

@heavy belfry

ionic karma
upbeat otter
#

and use your prefix instead of !

ionic karma
heavy belfry
#

without bot it will not connetct to my discord tho

ionic karma
#

Bruh

#

`

upbeat otter
heavy belfry
upbeat otter
ionic karma
upbeat otter
#

try it

upbeat otter
slate swan
upbeat otter
slate swan
#

Also help_command=None? rooThink You don't need help command?

ionic karma
upbeat otter
#

@slate swanCan u help me a bit too?

wary ravine
upbeat otter
heavy belfry
# upbeat otter use what i have given u, delete both bot and client from your orginial code
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'

slate swan
upbeat otter
slate swan
wary ravine
upbeat otter
#

i want to store the number of messages sent by each user in a json file, anybody can help me?

slate swan
pure totem
slate swan