#discord-bots

1 messages Β· Page 1018 of 1

tall dust
#

lets get back to discord botting thanks

gaunt ice
#

tru

paper sluice
#

these files are allowed

slate swan
#

Um sry

#

mhm never seen it

worldly gust
#

okimii help pwease

slate swan
#

Cuz ppl usually send offensive mp3/4

gaunt ice
#

not everyone

slate swan
#

Ye im sry

gaunt ice
#

it's fine

worldly gust
#

this is nextcord btw

gaunt ice
#

on_ready is an event where it triggers when the bot is ready to run

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

slate swan
gaunt ice
#

yes

worldly gust
slate swan
#

πŸ‘οΈπŸ‘οΈ

worldly gust
#

I learned python a while back, just forgot it cause of a lot of java coding

slate swan
worldly gust
slate swan
worldly gust
#

welp I shall do my best, thanks for all the help, and if I manage to keep the motivation for this I will update you when I get it joe_salute

slate swan
#

i belive in you!

near bronze
#

Hello anyone here?

slate swan
#

Yes

brittle axle
#

but yes you can get

near bronze
#

How to add emote reaction to a bot?

#

Like I have a bot which when a user sends hello , it reacts to the MSG by an emoji πŸ‘‹

near bronze
dusky pine
brittle axle
slate swan
#
await ctx.message.add_reaction("πŸ‘‹") 
#

is the right one for his situation

#

What if on message event

near bronze
#

What if the emote is in only in my server

slate swan
#

Lol

#

then yes that is so

slate swan
#

!d discord.ext.commands.Context.guild

unkempt canyonBOT
slate swan
unkempt canyonBOT
slate swan
#

Ok

near bronze
#

No i mean if the emote is custom made then how to do it?

slate swan
#

U mean server emojis

#

then you would need to get the object

near bronze
slate swan
#

bro

#

!d discord.ext.commands.Bot.get_emoji

unkempt canyonBOT
slate swan
#

!d discord.Message.add_reaction

unkempt canyonBOT
#

await add_reaction(emoji, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Adds a reaction to the message.

The emoji may be a unicode emoji or a custom guild [`Emoji`](https://discordpy.readthedocs.io/en/master/api.html#discord.Emoji "discord.Emoji")...
slate swan
#

yep it can be an Emoji object

#

...

near bronze
#

Ok letme try

#

Thnx

pliant gulch
#

Or just use a str representation of the custom emoji

slate swan
#

you can aswell yeah

short silo
#

What can be used to identify users across chats, user_id is constant right ?

slate swan
#

yes user ids are unique hence why they are called snoflakes

short silo
#

Alr thnx

slate swan
#

because snowflakes are always unique

#

Ohh

#

you never see identical snowflakes

#

if you get snow at a time of the year go outside and see the snowflakes and youll see how none of them are the same

paper sluice
#

FINALLY

buoyant zodiac
#

How can i get a single channel from the list of channels

slate swan
#

its just a list of objects?

paper sluice
#

list_of_channels[index]

slate swan
#

you would index them or just use iteration

slate swan
paper sluice
#

fixed the seg fault

slate swan
#

the what

paper sluice
#

segmentation fault

slate swan
#

still dont get what you mean

paper sluice
slate swan
#

how can i get total members of a guild ?

slate swan
unkempt canyonBOT
#

property member_count```
Returns the member count if available.

Warning

Due to a Discord limitation, in order for this attribute to remain up-to-date and
accurate, it requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be specified...
pliant gulch
stiff gorge
#

how to use a animated in embed ?
when i type <:name:id> it dosent work

paper sluice
pliant gulch
#

Ok I was about to say how did you manage to segfault in python

paper sluice
#

i think i have seen seg faults in python

pliant gulch
#

But could be achieved via ctypes bullshittery

paper sluice
#

from ctypes, yeah

pliant gulch
#

Pointers are scary 😳

gaunt ice
#

frug

#

I'm bad with the path

slate swan
gaunt ice
#

ok

#

delete_after

#

just search that on Google that's it

#

nope

#

ohh

#

then

#

do u want the users message to be deleted?

#

or the bots cooldwon message

#

alr

#

ohh

#

hmm

#

giv a min

#

rn does this error handler work

#

show the whole event

#

and the embed

#

yes

#

just a line above

#

umm

#

commands.Cog.listen?

#

ukw

worldly gust
#

I consider this a huge success

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

gaunt ice
#

yes

#

use tis

gaunt ice
#

i made it so that whenever someone mentions my name it reacts with skull

torn sail
#

await ctx.message.delete()

gaunt ice
#

bruh

#

lol

#

u mentioned ctx in embed footer πŸ˜†

#

hmhm

slate swan
#

is it possible to get the bot count and human count of a guild?

gaunt ice
#

user*

slate swan
gaunt ice
#

ugh

slate swan
#

or maybe a doc?

gaunt ice
#

wait

#

alr i give up

#

just a min

slate swan
#

nvm

gaunt ice
#

I'll send u the docs

pliant gulch
#

!d discord.User.bot

unkempt canyonBOT
gaunt ice
#

......

slate swan
gaunt ice
#

ig now u shud use for loop to check it

slate swan
#

i want the count of bot and humans

gaunt ice
#

yes

#

i understand

#

what I'm saying is

#

membercount gives both bots and members

#

and there isn't a doc for seperating to my knowledge

pliant gulch
#

You need to filter out bot.users then call len

gaunt ice
#

yes

pliant gulch
#

!d filter or you can also use sum

unkempt canyonBOT
#

filter(function, iterable)```
Construct an iterator from those elements of *iterable* for which *function* returns true. *iterable* may be either a sequence, a container which supports iteration, or an iterator. If *function* is `None`, the identity function is assumed, that is, all elements of *iterable* that are false are removed.

Note that `filter(function, iterable)` is equivalent to the generator expression `(item for item in iterable if function(item))` if function is not `None` and `(item for item in iterable if item)` if function is `None`.

See [`itertools.filterfalse()`](https://docs.python.org/3/library/itertools.html#itertools.filterfalse "itertools.filterfalse") for the complementary function that returns elements of *iterable* for which *function* returns false.
near bronze
#

Anyway I can find the list of reactions in a particular msg?

near bronze
# unkempt canyon

Like for this msg , it prints "reactions -> (now here dustbin emote)"

slate swan
near bronze
#

Any help sir?

slate swan
unkempt canyonBOT
manic path
#

Umm, even though my extension was loaded my bot says cannot find command.
Why is that?

slate swan
#

is it possible to get count of users who have admin perms? in a guild

torn sail
#

if ctx.message.channel == discord.channel.DMChannel won’t work. Use if not ctx.guild or if isinstance(ctx.channel, discord.DMChannel)

supple thorn
unkempt canyonBOT
#

property guild_permissions```
Returns the member’s guild permissions.

This only takes into consideration the guild permissions
and not most of the implied permissions or any of the
channel permission overwrites. For 100% accurate permission
calculation, please use [`abc.GuildChannel.permissions_for()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.GuildChannel.permissions_for "discord.abc.GuildChannel.permissions_for")...
slate swan
supple thorn
supple thorn
#

Can't guarantee cause i don't experiment that much anymore

slate swan
#

What would even be the purpose of the invite

rare saddle
#

Can you please tell me how to display all warnings?

slate swan
#

Creators one

#

Ig

slate swan
slate swan
#

Like this?

#

No that won't do anything

#

So sir?

#

As they said

#
my_string = "[My link](https://google.com)"
#

Can you write for me i am dumb πŸ˜‚@slate swan

#

I literally wrote it above

#

Try to put what's in the "" above in your field value

slate swan
#

My link?

#

That would be Derek_xD or Soul_xD in this example.

#

[Derek_xD](https://google.com)

#

embed.set_field_at(name='Creators', value="Sparky and Sparky2", inline=False)

#

Like this

#

Hmm

#

The URL

#

is to put a hyperlink, clicking on the blue text is like clicking on this: https://google.com

#

Hmm

#

So you can put, for example, your GitHub URL

#

Ohhh

#

But how put discord url?

#

Bro

#

Just copy paste the link

#

Hmm

#

Ok

#

Thx

#

Wow cool

alpine pewter
#
server_ids = [123, 345, 567, 789]

url = f"https://api.nitrado.net/services/{server_ids}/gameservers/games/players"

response = requests.get(url).json()
print(response)

When anyone gets second, can someone show me how to filter multiple the four {server_ids} through one URL.
Rather than making multiple different URLs.

slate swan
#

Cooll

slate swan
stone beacon
#

If the api supports one id at a time you won't be able to add multiple

slate swan
alpine pewter
slate swan
stone beacon
#

nah that won't work

#

The api needs a single id not a list of them

#

so you gotta choose an id rom the list then format it into the url and send the request

slate swan
#

@slate swan

alpine pewter
#

Ahh, alright.
Do you have any suggestions on how to compact it more?
I have 12 different server_ids I'd need to put through the URL

slate swan
#

Ok

#

@slate swan

stone beacon
slate swan
alpine pewter
#

That looks painful to even look at

#

Idk if I did that right

stone beacon
#

Unless the api has an endpoint that allows you to put multiple ids like ?id=[1,2,3] etc then u gotta do them individual

slate swan
#

!indents

unkempt canyonBOT
#

Indentation

Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.

Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.

Example

def foo():
    bar = 'baz'  # indented one level
    if bar == 'baz':
        print('ham')  # indented two levels
    return bar  # indented one level

The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.

Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines

More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation

slate swan
#

Make sure you read and apply these indentation levels correctly.

stone beacon
slate swan
#

Would be {id} in that case

stone beacon
#

ri ri

alpine pewter
slate swan
stone beacon
#

Doubt that's for a bot

alpine pewter
#

Oh, it is. It's a large project

stone beacon
#

πŸ‘€ then again

slate swan
alpine pewter
#

A project I can't even get the foundation of

stone beacon
#

Then u gotta use async requests m8 mb

alpine pewter
#

So, if I'm understanding it right

alpine pewter
slate swan
#

Right

alpine pewter
#

I've never used a for-loop with a list before, that's why I was wondering pepesabre

silver wolf
#

How do I know which select option was selected? I'm subclassing discord.ui.Select and using it's callback

alpine pewter
#

I appreciate you both @slate swan @stone beacon

#

It worked lol

alpine pewter
#

It saved me like 60 lines of code

stone beacon
#

That's standard for the avg d.py fork

alpine pewter
#

So, if I used AIOHTTP, would it be quick enough, like under 3s?

#

If it's 12+ ids

stone beacon
#

!d discord.ui.Select.callback

unkempt canyonBOT
#

await callback(interaction)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

The callback associated with this UI item.

This can be overridden by subclasses.
stone beacon
#

!d discord.Interaction.data

unkempt canyonBOT
stone beacon
#

Don't get yourself banned

#

Now time to sleep adios

alpine pewter
slate swan
#

pls send documentation

unkempt canyonBOT
shell wing
#

how can i get a channel like the current channel no need to mention it

silent portal
#

Is there a function for "display_banner"?

shell wing
# silent portal wdym?

like im making a lock channel command...and i want to eliminate the need of mentioning the channel

#

when i run !lock the bot locks the channel in which this cmd was run

#

no need to mention a channel

silent portal
#

you can get the channel by using ctx.channel

#

If you don't know how, I can help you

shell wing
slate swan
#

How to solve this?

silent portal
shell wing
#
@commands.command()
    @has_permissions(administrator=True)
    async def lockdown(self, ctx):
      role = 934391119041687593
      overwrite = channel.overwrites_for(role)
      overwrite.send_messages = True
#

this is my current code (not complete ofc)

#

i just need to eliminate the need of mentioning the channel

slate swan
shell wing
silent portal
slate swan
#

hmm

shell wing
#

and it depends on the cmd

slate swan
#

await asyncio.sleep(10) correct?

shell wing
#

yup

silent portal
#

@shell wing

@bot.command
@has_permissions(administrator=True)
async def lock(ctx):
    role = 934391119041687593
    channel = ctx.channel
shell wing
#

ah cool

slate swan
#

i want eval code anyone?

silent portal
# shell wing ah cool

You can just use ctx.channel instead of channel. CTX is the CONTEXT. You can get every info of the command of of it.

ctx.author = the member who sent the command
ctx.message = the message of the command
ctx.channel = the channel of where the command sent
ctx.guild = the guild of where the command sent

You have to use ctx very often in those use cases. Especially when using commands like these

slate swan
#

So I wanted to code a slash commands bot. And it kinda works. The bot only catches up the first two slash commands but idk why it doesn’t catch up the others although the code is nearly the same as command 1 and 2.

slate swan
#

ye wait a sec

silent portal
#

sure take ur time

slate swan
#

getting this error while creating a sticker: Error while creating sticker: 400 Bad Request (error code: 50046): Invalid Asset
this is my code:

        file = disnake.File('./temp_sticker_file')
        try:
            await inter.guild.create_sticker(name=sticker_name, emoji=sticker_emoji, file=file, description="test")
            await inter.send("Created sticker.")
        except Exception as e:
            await inter.send(f"Error while creating sticker: {e}")

any idea what i am missing?

#

can confirm ./temp_sticker_file is valid

slate swan
#

yeah

quaint epoch
#

if so add the extension at the end ./temp_sticker_file.png

slate swan
#

hmmm

quaint epoch
#

and if it is greater than the emoji size limit, like 250 kb or whatever, it won't work

#

so make sure it fits that

silent portal
#

@quaint epoch Only 14 y/o! wow respect man

quaint epoch
#

my b day is on 28 oct, so it rounded it up

silent portal
#

Oh I see

slate swan
#

how to write number of people with status

stiff gorge
#
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: type object 'Image' has no attribute 'open'
slate swan
#

e.g. online

silent portal
#

Oh

slate swan
quaint epoch
#

!d PIL.Image.open

unkempt canyonBOT
#

PIL.Image.open(fp, mode='r', formats=None)```
Opens and identifies the given image file.

This is a lazy operation; this function identifies the file, but
the file remains open and the actual image data is not read from
the file until you try to process the data (or call the
[`load()`](https://pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.Image.load "PIL.Image.Image.load") method). See
[`new()`](https://pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.new "PIL.Image.new"). See [File Handling in Pillow](https://pillow.readthedocs.io/en/stable/reference/open_files.html#file-handling).
stiff gorge
#

yes

quaint epoch
#

it, should work

silent portal
# slate swan yea

Wait I had a piece of code for that one. It's kinda old tho, but should work

slate swan
#

only I need the number of people with a certain status

quaint epoch
#

specifically the line it occurs on

stiff gorge
#

ok

quaint epoch
#

and what is data1 in this context?

#

is it a file obj?

stiff gorge
# quaint epoch send the full traceback
Ignoring exception in command smash:
Traceback (most recent call last):
  File "/home/runner/mv/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "/home/runner/mv/cogs/image.py", line 186, in smash
    smash = Image.open("Slap.jpg")
AttributeError: type object 'Image' has no attribute 'open'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/runner/mv/venv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/home/runner/mv/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/home/runner/mv/venv/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: AttributeError: type object 'Image' has no attribute 'open'
#
    @commands.command(name="smash")
    @commands.cooldown(rate=1, per=3.0, type=commands.BucketType.user)
    async def smash(self, ctx, user: Optional[Member]):
        user1 = ctx.author
        user2 = user if user else user1
        smash = Image.open("Slap.jpg")
        asset1 = user1.avatar_url_as(size=256)
        asset2 = user2.avatar_url_as(size=256)
        data1 = BytesIO(await asset1.read())
        data2 = BytesIO(await asset2.read())
        pfp1 = Image.open(data1)
        pfp1 = pfp1.resize((200, 200))
        smash.paste(pfp1, (600, 70))
        smash.save("Slap.jpg")
        pfp2 = Image.open(data2)
        pfp2 = pfp2.resize((200, 200))
        smash.paste(pfp2, (150, 58))
        smash.save("Slap.jpg")
        await ctx.send(file=discord.File("Slap.jpg"))
slate swan
# silent portal Can you show the code?

from discord import Client, Intents, Embed
from discord_slash import SlashCommand, SlashContext

bot = Client(intents=Intents.default())
slash = SlashCommand(bot)

@slash.slash(name="test")
async def test(ctx: SlashContext):
embed = Embed(title="Embed Test")
await ctx.send(embed=embed)

@slash.slash(name="test")
async def test(ctx: SlashContext):
embed2 = Embed(title="Embed Test")
await ctx.send(embed=embed2)

@slash.slash(name="test")
async def test(ctx: SlashContext):
embed2 = Embed(title="Embed Test")
await ctx.send(embed=embed2)

bot.run("discord_token")

So Iβ€˜m not on my pc rn. Cant show my code but it’s nearly like this

quaint epoch
#

kek gimme a bit my parents need something

silent portal
# slate swan ok
      guild = bot.get_guild(IDHERE)
            statuses = [
                len(list(filter(lambda m: str(m.status) == "online", guild.members))), # Gives the membercount of users ONLINE
                len(list(filter(lambda m: str(m.status) == "idle", guild.members))), # Gives the membercount of users IDLE
                len(list(filter(lambda m: str(m.status) == "dnd", guild.members))), # Gives the membercount of users DO NOT DISTURB
                len(list(filter(lambda m: str(m.status) == "offline", guild.members))) # Gives the membercount of users OFFLINE
                ]
slate swan
#
Ignoring exception in on_message_delete
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 "main.py", line 251, in on_message_delete
    await sleep(60)
NameError: name 'sleep' is not defined
#

yhx

silent portal
slate swan
silent portal
slate swan
#

oops

slate swan
silent portal
silent portal
# slate swan oops

tell me if it worked, the code is kinda old so I wanted to know if it works

quaint epoch
quaint epoch
#

although i just import the module entirely, since there are a lot of attrs i use

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.

slate swan
#
 File "main.py", line 252, in on_message_delete
    del snipe_message_author[message.channel.id]
KeyError: 970213202078085181
quaint epoch
quaint epoch
#

try printing out the dict before doing that, then show it here

quaint epoch
#

and the full traceback

slate swan
quaint epoch
#

nice pepe

#

traceback?

silent portal
slate swan
#

its like 128k in size

slate swan
#

Traceback (most recent call last):

quaint epoch
#

hmmm

slate swan
#

πŸ‘οΈ

quaint epoch
#

time to get some docs

stiff gorge
quaint epoch
silent portal
#

docs = love

quaint epoch
#

!d disnake.Guild.create_sticker

unkempt canyonBOT
#

await create_sticker(*, name, description=None, emoji, file, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Creates a [`Sticker`](https://docs.disnake.dev/en/latest/api.html#disnake.Sticker "disnake.Sticker") for the guild.

You must have [`manage_emojis_and_stickers`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.manage_emojis_and_stickers "disnake.Permissions.manage_emojis_and_stickers") permission to do this.

New in version 2.0.
quaint epoch
#

aha

stiff gorge
#

same error

quaint epoch
slate swan
#
@client.event
async def on_message_delete(message):
     snipe_message_author[message.channel.id] = message.author
     snipe_message_content[message.channel.id] = message.content
     await asyncio.sleep(60)
     del snipe_message_author[message.channel.id]
     del snipe_message_content[message.channel.id]
``` correct?
quaint epoch
#

did you overwrite Image anywhere?

#

because i think you did

slate swan
#

πŸ‘€

stiff gorge
#

yes

#

ig its bcz of tht

quaint epoch
stiff gorge
#

ohk

quaint epoch
#

do import PIL

stiff gorge
#

ty

quaint epoch
#

then replace all your Image.open parts with PIL.Image.open

slate swan
#
Ignoring exception in slash command 'stickersadd':
Traceback (most recent call last):
  File "/home/gwl/.local/lib/python3.10/site-packages/disnake/ext/commands/slash_core.py", line 597, in invoke
    await call_param_func(self.callback, inter, self.cog, **kwargs)
  File "/home/gwl/.local/lib/python3.10/site-packages/disnake/ext/commands/params.py", line 778, in call_param_func
    return await maybe_coroutine(safe_call, function, **kwargs)
  File "/home/gwl/.local/lib/python3.10/site-packages/disnake/utils.py", line 561, in maybe_coroutine
    return await value
  File "/home/gwl/pritam/code/python/yadps-chan/src/yadps/commands/cogs/admin/emojis.py", line 60, in stickersadd
    await inter.guild.create_sticker(name=sticker_name, emoji=sticker_emoji, file=file, description="test")
  File "/home/gwl/.local/lib/python3.10/site-packages/disnake/guild.py", line 2542, in create_sticker
    data = await self._state.http.create_guild_sticker(self.id, payload, file, reason=reason)
  File "/home/gwl/.local/lib/python3.10/site-packages/disnake/http.py", line 420, in request
    raise HTTPException(response, data)
disnake.errors.HTTPException: 400 Bad Request (error code: 50046): Invalid Asset

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/gwl/.local/lib/python3.10/site-packages/disnake/ext/commands/interaction_bot_base.py", line 1332, in process_application_commands
    await app_command.invoke(interaction)
  File "/home/gwl/.local/lib/python3.10/site-packages/disnake/ext/commands/slash_core.py", line 606, in invoke
    raise CommandInvokeError(exc) from exc
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 50046): Invalid Asset
#

i want eval codes anyone plz

quaint epoch
slate swan
#

yeah

slate swan
quaint epoch
#

try this~

slate swan
# slate swan yes

use regex to get anything between code blocks and use subprocess or something to get output of eval

#

My on_member_join isn’t working

#

No errors in console

slate swan
slate swan
unkempt canyonBOT
#

Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default discord.py has all intents enabled except for Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, and to get members' statuses.

To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.

Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

intents = Intents.default()
intents.members = True

bot = commands.Bot(command_prefix="!", intents=intents)

For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.

quaint epoch
#
await guild.create_sticker(name='name_here', description='sticker made by bot', file=discord.File('./image.jpg'))```
slate swan
#

what about emoji

quaint epoch
slate swan
#

idk too

slate swan
#

else you would have to use an external sandboxed environment

quaint epoch
slate swan
#

yea, snekbox is one of the options

#

ValueError: read of closed file what does this mean? i get this when i try to send the file to the channel

#
        file = disnake.File('./temp_sticker_file.jpg')

        await inter.send(file=file)
#

yea so sending the file works, its a valid file

unkempt canyonBOT
#

class disnake.File(fp, filename=None, *, spoiler=False, description=None)```
A parameter object used for sending file objects.

Note

File objects are single use and are not meant to be reused in multiple [`abc.Messageable.send()`](https://docs.disnake.dev/en/latest/api.html#disnake.abc.Messageable.send "disnake.abc.Messageable.send")s.
slate swan
#

no

#

not really, i was mistaken

quaint epoch
#

oh kek

slate swan
#

ye

quaint epoch
slate swan
#

on it

#

for whatever reason, i cant upload it, i do everything fine, the upload button doesnt work

#

the problem was in the image after all

slate swan
# slate swan !intents

AttributeError: β€˜Member’ object has no attribute β€˜author’

The command I use

@client.listen(β€˜on_member_join’)
async def on_member_join1(ctx):
    channel164 = client.get_channel()
    await channel164.send(f”{ctx.author.mention”, delete_after=3)
placid skiff
#

on_member_join is not a command, it is an event, and it not takes ctx as argument

#

!d discord.on_member_join

unkempt canyonBOT
#

discord.on_member_join(member)``````py

discord.on_member_remove(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") join or leaves a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").

This requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be enabled.
placid skiff
#

author is a member object that context use as a parameter, so type(Context.author) == type(discord.Member)

echo wasp
echo wasp
placid skiff
#

maybe he will understand with this example

placid skiff
#

Bruh it doesn't metter the error is that he is using a member object like a context object D_D

supple thorn
placid skiff
#

Hahahaha

echo wasp
supple thorn
placid skiff
#

Yeah i feel the same but what is the use to know if that is inside a cog or the library he is using? i mean, on_member_join is still the same for every package

supple thorn
#

πŸ—Ώ

supple thorn
echo wasp
supple thorn
# echo wasp what?

Why do you need to know if it's in or out of a cog the error isn't related to cogs

echo wasp
supple thorn
echo wasp
#

it don't work like that

supple thorn
#

Being in or outside of a cog is unrelated

echo wasp
#

it works like this

slate swan
supple thorn
#

Yeah

#

There's no point of you asking if it's in a cog or not

echo wasp
#
@bot.listener()
async def on_member_join(member):
  channel = bot.get_channel(id)
  await channel.send(f"Welcome {member.mention} to {member.guild}! Enjoy your stay!")```
supple thorn
#

The error isn't related to cogs

slate swan
echo wasp
placid skiff
placid skiff
#

you can use a listener even outside a cog

echo wasp
supple thorn
placid skiff
#

nope, it is bot.listener

supple thorn
#

I'm right

slate swan
#
@Bot.event
async def on_member_join(member: Member):
     ...
@Bot.listen("on_member_join")
async def uwu(member: Member): 
 ...```
slate swan
#

yeah phone

placid skiff
#

i want to make a project with you Ash

supple thorn
placid skiff
#

so we can call all the functions uwu

echo wasp
#
@client.listen(β€˜on_member_join’)
async def on_member_join1(member: discord.member):
    channel164 = client.get_channel()
    await channel164.send(f”{ctx.author.mention}”, delete_after=3)```
#

that how it should be right

slate swan
slate swan
#

how to make the bot stream?

slate swan
unkempt canyonBOT
#

class discord.Member```
Represents a Discord member to a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").

This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User")...
echo wasp
slate swan
placid skiff
slate swan
unkempt canyonBOT
#

class discord.Streaming(*, name, url, **extra)```
A slimmed down version of [`Activity`](https://discordpy.readthedocs.io/en/master/api.html#discord.Activity "discord.Activity") that represents a Discord streaming status.

This is typically displayed via **Streaming** on the official Discord client...
echo wasp
placid skiff
#

and inside of the readme we will have len("uwu".encode('utf-16')) MB of uwu written in it

placid skiff
echo wasp
#

it would show the bots current network speed not a discord user

placid skiff
#

well it is an app, so you have to find a way to open the app and execute the test and then read from it

#

it is not related to d.py also i think that it will be a pain in the ass

slate swan
#

I want to get a large data of all cricket players, can I get it?

#

I am developing a discord bot so I'm asking you guys

echo wasp
echo wasp
tawdry perch
supple thorn
#

Only ask here if you have actual problems with discord bots code

slate swan
#

k bro

echo wasp
#

Download is16335108
Upload is 3417004 bit/s how do i make it megabytes/s

slate swan
#

how to make it?

echo wasp
slate swan
#

uh

echo wasp
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

slate swan
slate swan
echo wasp
paper sluice
slate swan
#

@paper sluice guess what im making

#

related to giv

paper sluice
#

something realted you ur giv

slate swan
#

bru

slate swan
slate swan
paper sluice
#

then make it πŸ€·β€β™‚οΈ

paper sluice
slate swan
paper sluice
#

πŸ‘€ nice

slate swan
slate swan
#

you only need to have an administrator

#

he mean

#

ban members etc

#

yes

#

ye

paper sluice
slate swan
#

Lol

#

well, if the bot has permission to create roles, then it can create those roles that do not have permissions such as administrator, server management

livid jacinth
#

Hey how can i edit a channel?

slate swan
#

or perms

livid jacinth
#

No the perms

slate swan
#

yea

echo wasp
#

how do you devide a number by 1 million in a f string

livid jacinth
slate swan
potent spear
echo wasp
#
 @commands.command()
    async def speedtest(self,ctx):
        await ctx.channel.send("testing please wait")
        await ctx.channel.send(f"{ctx.author.mention} Download is{round(st.download() /=1000000.;)} Mbps \n Upload is {round(st.upload() /=1000000.;)} Mbps")
slate swan
potent spear
potent spear
slate swan
#

here is my code

#
@bot.command()
async def serverinfo(ctx):
    emb = discord.Embed(title=f"Information about {ctx.guild.name}", colour = discord.Color.light_grey())
    emb.add_field(name="Members:", value=f"<970598094129496085>Total: **{ctx.guild.member_count}**")
    emb.add_field(name="By Status:", value=f"Online: ")
    await ctx.reply(embed=emb)```
echo wasp
slate swan
#

second

#

can i edit a interaction.response.send_message()

livid jacinth
#

Hey, how can i edit channel perms?

potent spear
#

you first have to get the channelperms

slate swan
potent spear
echo wasp
slate swan
#
@bot.command()
async def serverinfo(ctx):
    emb = discord.Embed(title=f"Information about {ctx.guild.name}", colour = discord.Color.light_grey())
    emb.add_field(name="Members:", value=f":members_total:Total: **{ctx.guild.member_count}**")
    emb.add_field(name="By Status:", value=f"Online: ")
    await ctx.reply(embed=emb)```
#

do u want emoji?

#

yes

#

..

livid jacinth
slate swan
#

-__________-

#

wait

slow fog
#

πŸ—Ώ

slate swan
#

where error?

slow fog
#

πŸ—Ώ

slate swan
#

lol

slate swan
#

no

slow fog
slate swan
#

wait...

#

I don't understand

#

nothing has changed

maiden fable
#

What happened

slate swan
#

Guys, I have a question, how to do the bot, who will delete any discord invite links

maiden fable
#

I don't think u can have an emoji in a field value @slate swan

slate swan
#

I have bot who is deleting bad words

unkempt canyonBOT
#

discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") is created and sent.

This requires [`Intents.messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.messages "discord.Intents.messages") to be enabled...
slate swan
#

Not my bot

#
@client.event
async def on_message(message):
    if any(word in message.content.lower() for word in ["lol", "haha"]):
        await message.delete()

I have this

slate swan
maiden fable
#

I guess?

slate swan
#

do like this ?

@client.event
async def on_message(message):
    if any(word in message.content.lower() for word in ["lol", "haha", "discord.gg"]):
        await message.delete()
slate swan
slate swan
slate swan
#

ok

slate swan
#
@bot.command()
async def serverinfo(ctx):
    emb = discord.Embed(title=f"Information about {ctx.guild.name}", colour = discord.Color.light_grey())
    emb.add_field(name="Members:", value=f":kiff: Total: **{ctx.guild.member_count}**")
    emb.add_field(name="By Status:", value=f"Online: ")
    await ctx.reply(embed=emb)```
#

where is the mistake?

sweet chasm
#

is that a custom emoji

slate swan
#

yes

sweet chasm
#

custom emojis need to be formatted like <:emoji_name:emoji_id>

slate swan
#

here

sweet chasm
#

try that see if it works

slate swan
manic path
#

Umm, this message might be a bit long, but it explains my problem in detail, so bear with me please.

supple thorn
slate swan
#

no

manic path
#

So my problem is I keep getting

    bot_ = Bot(
  File "/Users/inheritanc-e/Desktop/The_Rationals/new_rationals/bot/bot.py", line 27, in __init__
    self.pool = Connection(self.loop).pool
  File "/Users/inheritanc-e/Desktop/The_Rationals/new_rationals/bot/db/connection.py", line 29, in __init__
    self.pool = self.loop.run_until_complete(self.create_connection_pool())
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 622, in run_until_complete
    self._check_running()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 582, in _check_running
    raise RuntimeError('This event loop is already running')
RuntimeError: This event loop is already running

in my connection class for my database there is:

    def __init__(self, loop):
        self.loop = loop 
        self.pool = self.loop.run_until_complete(self.create_connection_pool())

i supply the pool for the connection class in another class which is a subclass of discord.ext.commands.Bot. There I have:

    def __init__(self, *a, **kw) -> None:
        super().__init__(*a, **kw)
        self.http_session = aiohttp.ClientSession()
        self.loop = asyncio.get_event_loop()
        self.pool = Connection(self.loop).pool

And in my main file, through which I am running the bot, the code is as follows:

async def main():
    bot_ = Bot(
        command_prefix=("|"),
        case_insensitive=False,
        allowed_mentions=AllowedMentions(everyone=False),
        activity=discord.Game(name=f"Commands: {Rationals.prefix}help"),
        intents=intents
    )

    await load_all_extensions(bot_)
    await bot_.start(Rationals.token, reconnect=True)
asyncio.run(main())

I don't understand why I keep getting that error, because I am suppling the same asyncio connection db and the bot (or I think I am).

supple thorn
slate swan
#

:kiff:

#

id not show

sweet chasm
sweet chasm
manic path
manic path
#

hmm, I'll do that ig. Thanks!

formal basin
#

Does anyone know how I can make a slash command only respond to the user like if I type /test it will say hi but only that user can see hi

formal basin
sweet chasm
#

no sadly that's not possible

little ether
#

those are called ephemeral messages btw

formal basin
sweet chasm
#

ok yeah I was wrong you can

#

You can only send an ephemeral message as a response to an interaction, eg. as a response to a button click or a slash command using interaction.response.send_message("Text", ephemeral=True)

little ether
slate swan
#

is it value and name?

sweet chasm
#

<:emoji_name:emoji_id>

#

in your server, just type in \:kiff:

slate swan
#

Total, members, bots

#

My discord bot stops working after 6 minutes of usage, i can use commands 2-4 times but then it just wont respond back to any command anyone know why?

slate swan
formal basin
formal basin
slate swan
#

what library?

formal basin
sweet chasm
slate swan
slate swan
#

thats what i asked, what is it?

little ether
slate swan
#

totally not dpy app command

little ether
#

discord_slash.

slate swan
#

Why would you still use a third part library Think

#

cause outdated tutorials and thats what i found on google~

#

πŸ₯² and why even discord_slash when the devs migrated to interactions.py

slate swan
#

It's await interaction.send(...)

#

It's just that, as the error says, it's not ephemeral=True but hidden=True

slate swan
#

how to make it?

#

bro

#

we have told u like 5 times

#

total, members and bots in Members

#

len(guild.members)

slate swan
#

claim a help channel

slate swan
#

?

#

hmmhmhmh

#

I can't formulate a thought

#

how to do it?

dull terrace
slate swan
#

@dull terrace help

#

Members:
Total:
Members:
Bots:

dull terrace
#

oh god, i've only done a modal in disnake once before

slate swan
dull terrace
# slate swan i have not done even once

This is a short video showing you two ways of using Discord's new modals system with Disnake.

Read description for links!

----------------------------------------Β­Β­---------------------------------------Β­-Β­--

Need Help?
Require help with your code? Why not head on over to our dedicated support discord where you can receive only the best suppo...

β–Ά Play video
#

this video was great help

slate swan
#

i found this website

#

uh wait

dull terrace
#

what part are you stuck on

slate swan
#

wait

slate swan
#

i get it

dull terrace
#

what you've done looks good so far

slate swan
#

its inter.response.send_modal

dull terrace
#

yeah it's got a special thing

slate swan
#

works fine

#

:D

slate swan
#

yeah, its been like a few weeks since its out

lyric apex
#

!d code

slate swan
#

how to make it?

#

send documentation pls

lyric apex
#
    @commands.command()
    async def play(self, ctx, *, song=None):
        if song is None:
            return await ctx.send("You must include a song to play.")

        if ctx.voice_client is None:
            return await ctx.send("I must be in a voice channel to play a song.")

        # handle song where song isn't url
        if not ("youtube.com/watch?" in song or "https://youtu.be/" in song):
            await ctx.send("Searching for song, this may take a few seconds.")

            result = await self.search_song(1, song, get_url=True)

            if result is None:
                return await ctx.send("Sorry, I could not find the given song, try using my search command.")

            song = result[0]

        if ctx.voice_client.source is not None:
            queue_len = len(self.song_queue[ctx.guild.id])

            if queue_len < 10:
                self.song_queue[ctx.guild.id].append(song)
                return await ctx.send(f"I am currently playing a song, this song has been added to the queue at position: {queue_len+1}.")

            else:
                return await ctx.send("Sorry, I can only queue up to 10 songs, please wait for the current song to finish.")

        await self.play_song(ctx, song)
        await ctx.send(f"Now playing: {song}")```
lyric apex
#

I am getting this error whats the problem?shipit

jade tartan
#

Can someone help me

slate swan
#

my slash commands just randomly stopped showing? any idea?

#

Hey there, interaction.guild is not working when I use buttons.
Please help.

boreal ravine
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)
quaint epoch
#

!d disnake.Interaction.guild

unkempt canyonBOT
quaint epoch
#

show code and traceback

slate swan
slate swan
unkempt canyonBOT
#

set_thumbnail(*, url)```
Sets the thumbnail for the embed content.

This function returns the class instance to allow for fluent-style
chaining.

Changed in version 1.4: Passing `None` removes the thumbnail.
slate swan
#

or if you were talking about the eye....

paper sluice
#

how to make eye

slate swan
supple thorn
paper sluice
#

how?

#

||its not coccaine i can't grow it||

slate swan
#

eyes dont grow

jade tartan
#

Hello anyone

supple thorn
#

It's a 2 person job and takes about 9 months

paper sluice
#

i just want eye

#

not the whole package

supple thorn
#

From the blind

#

They already can't see

#

Might aswell take them

paper sluice
#

pithink i want a working eye

#

i will steal pikchu's eyes, why not

supple thorn
#

Or from the elderly

#

Already lived a good life and seen a lot of things

#

Take em

paper sluice
#

hmm

#

new mission: steal eyes

slate swan
#

how to make thumbnail with a picture of the server

#

?

quaint epoch
#

nice

supple thorn
unkempt canyonBOT
quaint epoch
supple thorn
#

Fast

slate swan
#

thx

supple thorn
slate swan
quaint epoch
slate swan
#

?????

quaint epoch
#

url=guild.icon.url

#

it returns a discord.Asset

#

not the url

slate swan
#

guild.icon_url?

quaint epoch
#

no

manic path
#
    raise PrivilegedIntentsRequired(exc.shard_id) from None
discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead.

Umm, what is this saying?
I didn't find anything called Shard ID in developer portal

slate swan
#
emb.set_thumbnail(url=guild.icon.url)?```
paper sluice
quaint epoch
#

it's 15 ms now

paper sluice
#

hex

slate swan
#

???????

quaint epoch
paper sluice
#

define guild

paper sluice
slate swan
paper sluice
#

guild = ctx.guild or smthing

slate swan
#

thx

#

or just use ctx.guild.icon.url

jade tartan
paper sluice
#

what is not working

slate swan
#

you need to decorate the on_message

#

commands.Cog.listener("on_message"); async def my_on_message(self, message:)

paper sluice
#

the class ur using doesn't subclass from commands.Cog

slate swan
#

^ you want something like class Levels(commands.Cog)

jade tartan
#

Well now its giving me a whole bunch of 15 errors

#

so thats great

slate swan
#

new errors is progress

#

you cant expect us to mindread your problem and magically know all the correct solutions

boreal ravine
paper sluice
#

its worse

supple thorn
jade tartan
quaint epoch
#

do you think i hold the record of highest bot ping?

paper sluice
quaint epoch
#

i could probably shoot higher

paper sluice
supple thorn
quaint epoch
#

now we wait

jade tartan
supple thorn
#

And it just sends out data and pictures

quaint epoch
#

im waiting for it to lag

#

nothing is responding lol

supple thorn
supple thorn
jade tartan
#

True but my @commands.command() async def level(self, ctx, member: discord.Member = None): Doesnt seem to work

#

discord.ext.commands.errors.CommandNotFound: Command "level" is not found

supple thorn
jade tartan
#

The latest version yes

supple thorn
#

@jade tartan it's async

#

The setup version is async

#

And add_cog is a courotine now

#

!d discord.ext.commands.Bot.add_cog

unkempt canyonBOT
#

await add_cog(cog, /, *, override=False, guild=..., guilds=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Adds a β€œcog” to the bot.

A cog is a class that has its own event listeners and commands...
supple thorn
#

Even for a small leveling system

jade tartan
supple thorn
scarlet rune
#

yo how do i skip default role?

supple thorn
#

Just make your setup function asynchronous

granite parcel
#

where i paste my code?

supple thorn
#

And make your add cog a courotine

supple thorn
unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

boreal ravine
granite parcel
supple thorn
#

I was going through the docs

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)
jade tartan
slate swan
#

I’ve got txt of user ids for verify for command but I wanna check make it so it doesn’t make duplicate user ids

supple thorn
scarlet rune
supple thorn
#

You already have it

#

You just change it to a courotine

jade tartan
slate swan
#

how to make verification level?

supple thorn
slate swan
#

hmmhmhmh

#

wait

#

Verification lvl

supple thorn
supple thorn
slate swan
#

when creating a server, you can specify the level of verification

supple thorn
#

Oh that

slate swan
#

if it is high, then you need to have mail

supple thorn
#

Can bots even check that?

#

!d discord.Guild

unkempt canyonBOT
#

class discord.Guild```
Represents a Discord guild.

This is referred to as a β€œserver” in the official Discord UI...
slate swan
manic path
#
    raise PrivilegedIntentsRequired(exc.shard_id) from None
discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead.

Ummmmm, but I have enabled privileged intents explicitly from the developer portal, so why am I getting this error?

supple thorn
unkempt canyonBOT
#

The guild’s Multi-Factor Authentication requirement level.

Changed in version 2.0: This field is now an enum instead of an int.

supple thorn
#

Maybe this?

slate swan
#

second

slate swan
manic path
#

intents = discord.Intents.all()

supple thorn
manic path
#

thats what I did

supple thorn
supple thorn
unkempt canyonBOT
#

class discord.VerificationLevel```
Specifies a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild")'s verification level, which is the criteria in
which a member must meet before being able to send messages to the guild...
supple thorn
#

I'll keep that name in mind

supple thorn
#

You'd have to enable message content too

#

In the portal

manic path
#

But it won't be enforced till August 31, 2022

#

so what do I do?
set intents.message_content = False?

slate swan
#

you can either add member and presences intents as True to .default() or set message_content to false from .all()

manic path
#
    intents = discord.Intents.all()
    intents.message_content = False

#

lets try this

slate swan
#

should work :3

manic path
#

cool it works

#

Thanks!

tired hinge
#

how can i get the amount of messages ever sent in a channel?

slate swan
#

how to write the number of channels on the server?

pseudo portal
#

using pycord, tryina make the bot be able to list invites to all servers its on.. failing lol

invites = []

for guild in bot.guilds:
    for c in guild.text_channels:
        if c.permissions_for(guild.me).create_instant_invite:  
            invite = await c.create_invite()
            invites.append(invite)
            break  

what am i doin wrong?

rain salmon
#

i have a discord bot that uses interactions but it does not show up in the list with the slash commands even if it runs

quaint epoch
#

!d disnake.Guild.invites

unkempt canyonBOT
#

await invites()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Returns a list of all active instant invites from the guild.

You must have [`manage_guild`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.manage_guild "disnake.Permissions.manage_guild") permission to use this.
quaint epoch
#

@pseudo portal

pseudo portal
slate swan
unkempt canyonBOT
slate swan
#

use len on this

slate swan
#

thats what's happening right?

pseudo portal
slate swan
#

just create the invite for the first text channel

#

how to send emoji?=>

pseudo portal
slate swan
unkempt canyonBOT
#
Nope.

No documentation found for the requested symbol.

slate swan
#

oof, well, bot.get_emoji(id)

#

and send it

slate swan
rain salmon
#

i have a discord bot that uses interactions but it does not show up in the list with the slash commands even if it runs

slate swan
#

wherever you want to use the emoji~

slate swan
rain salmon
#

but.. tbh idk if an hour passed but thank you xd

#

ty ty

granite parcel
#

how to set image as attachment

pseudo portal
slate swan
slate swan
#

!e print([1,2,3][0])

unkempt canyonBOT
#

@slate swan :white_check_mark: Your eval job has completed with return code 0.

1
slate swan
#

like this

#

oops

granite parcel
#

!d attachment

unkempt canyonBOT
#

Qt Style Sheets support various properties, pseudo-states, and subcontrols that make it possible to customize the look of widgets.

slate swan
#
@bot.command()
async def serverinfo(ctx):
    emb = discord.Embed(title=f"Information about {ctx.guild.name}", colour = discord.Color.light_grey())
    guild = ctx.guild
    list_of_bots = [bot.mention for bot in ctx.guild.members if bot.bot]
    emb.add_field(name="Members:", value=f"""
    Total: **{ctx.guild.member_count}**
    Members: **{len([Member for Member in ctx.guild.members if not Member.bot])}**
    Bots: **{len(list_of_bots)}**""")
    emb.add_field(name="By status", value="""
    Online:
    Offline:
    Do Not Disturb:
    Idle:""")
    emb.add_field(name="Channels:", value=f"""
    Total:
    Text:
    Voice:""")
    emb.add_field(name="Owner:", value=f"{ctx.guild.owner}")
    emb.add_field(name="bot.get_emoji(970653782444744744)Verification Level:", value=f"d")
    emb.add_field(name="Created at:", value="None")
    emb.set_thumbnail(url=guild.icon_url)
    await ctx.reply(embed=emb)```
pseudo portal
slate swan
pseudo portal
slate swan
#

and, if the emoji didn't exist for bot, it would simply appear as None instead of its name.

pseudo portal
#

oooh

slate swan
#

oops

#

kaif, does the bot have external emojis permissions in the server?

#

and f i just realised im facing the same issue

#

he admin

#

the emojis used to appear till tomorrow, now it does not

#

you use translator?

#

what kind of translator?

#

oh, I'm just from Ukraine and my English so bad

#

:3

brave forge
#

how do I make a command that will add forbidden words to a json file ??

swift crane
#

do you know how to make word filter?

brave forge
#

that is, which line of code is responsible for adding it?

#

@swift crane
well, my type is working right now. So

    if {i.lower().translate(str.maketrans('','', string.punctuation)) for i in message.content.split(' ')}\
        .intersection(set(json.load(open('cenz.json')))) != set():
        await message.delete()```
#

here I want to be able to add certain words to this json file myself

swift crane
#

i want to put words in list

#

and if any msg contains it

#

make bot to do thomeshing

supple thorn
supple thorn
unkempt canyonBOT
#

discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") is created and sent.

This requires [`Intents.messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.messages "discord.Intents.messages") to be enabled...
brave forge
#

@supple thorn What 's this for ?

swift crane
#

I can't use json files

brave forge
#

@supple thorn I don't need an event

supple thorn
#

I'm not saying that to you

glad thicket
#

hey quick question I just created a slash command(using discord-slash) in a cog that is in a different file then the main but it's not working it's not shown or called when I do the command

#Slash.py
from discord.ext import commands
from discord_slash import cog_ext, SlashContext

class Slash(commands.Cog):
    def __init__(self, bot:commands.Bot):
        self.bot = bot

    @cog_ext.cog_slash(name="slash", description="first slash command of this bot")
    def _slash(self, ctx: SlashContext):
        ctx.send("Slash")

def setup(bot:commands.Bot):
    bot.add_cog(Slash(bot))
supple thorn
#

I'm saying it to nikita

supple thorn
glad thicket
#

where how?

supple thorn
swift crane
#

so...

glad thicket
#

when was this update??

swift crane
#

i can't find if word is in list

supple thorn
supple thorn
#

Just check if the message content matches any item inside your list

swift crane
#

i have word list

supple thorn
#

If it does then do what you want to it

glad thicket
silver agate
supple thorn
#

Also

supple thorn
glad thicket
#

when will this be pushed to pip

supple thorn
#

Well minor

swift crane
#
badwords = ["bla", "blu", "ble"]

@bot.event
async def on_message(msg):
   if badwords in msg.content:
      await ctx.message.delete()