#discord-bots

1 messages Β· Page 886 of 1

maiden fable
#

Not everyone, just newbies lemon_pensive

slate swan
#

so, first you make a command manually with a decorator

maiden fable
#

100 servers*

slate swan
drowsy thunder
#

Ok @client.commands()

slate swan
drowsy thunder
#

@slate swan can you dm me?
This slowmode sucks

slate swan
#

no, I dont do dms, hunter does

slate swan
# maiden fable 100 servers*

you can request for the verification on 75 itself and maybe if you're unlucky you may not get the message intents 🀑
But yeah, 100

drowsy thunder
#

Ok

maiden fable
# slate swan 75

Max server limit for unverified bots are 100, that's why I said that, but okay

drowsy thunder
#

Brb
Lemme get my token and make a repl
Stay here

slate swan
#

type in 1 line and the slowmode won't suvk

slate swan
maiden fable
#

Let's ping a mod to reduce the slowmo

#

@blissful lagoon can u please reduce the slowmo duration of the channel?

drowsy thunder
#

Got the token now lemme do the importing and stuff

maiden fable
#

Cool

spring flax
#

can anyone tell me how to access my bot instance in a Modal?
I have a button that sends the modal

slate swan
maiden fable
slate swan
slate swan
maiden fable
maiden fable
unkempt canyonBOT
spring flax
#

they have disnake.ModalInteraction

maiden fable
#

Oh, hmm

spring flax
maiden fable
#

!d disnake.ModalInteraction.user

unkempt canyonBOT
#

property user```
The user or member that sent the interaction. There is an alias for this named [`author`](https://docs.disnake.dev/en/latest/api.html#disnake.ModalInteraction.author "disnake.ModalInteraction.author").
maiden fable
#

Ouh, that was a wild guess

keen talon
boreal ravine
manic wing
#

am i the only one whos never even seen a modal

maiden fable
drowsy thunder
#

I cant paste my token aaaa
I will need to manually send it

spring flax
slate swan
spring flax
maiden fable
slate swan
unkempt canyonBOT
#

property bot```
The bot handling the interaction.

Only applicable when used with [`Bot`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.Bot "disnake.ext.commands.Bot"). This is an alias for [`client`](https://docs.disnake.dev/en/latest/api.html#disnake.ModalInteraction.client "disnake.ModalInteraction.client").
slate swan
spring flax
#

oh

#

lmao

boreal ravine
#

ok

maiden fable
maiden fable
drowsy thunder
maiden fable
#

!e

def require(p):
    import p
require(random) 
unkempt canyonBOT
#

@maiden fable :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 3, in <module>
003 | NameError: name 'random' is not defined
maiden fable
slate swan
boreal ravine
#

!ot

unkempt canyonBOT
slate swan
unkempt canyonBOT
slate swan
unkempt canyonBOT
slate swan
boreal ravine
vale sierra
#

hello guys, my code in sublime text looks like this, how can i do reconvert to the normal looks cause my bot commands don't work

keen talon
vale sierra
boreal ravine
#

well

drowsy thunder
#

@slate swan I am ready,what now?
I imported discord and did the setup and stuff

boreal ravine
#

your fucked, fix it manually

vale sierra
#

@boreal ravine alr thanks mate

slate swan
slate swan
#

or maybe they indented commands inside commands

drowsy thunder
#

@maiden fable ...

slate swan
slate swan
cold sonnet
slate swan
#

ohisee

drowsy thunder
#

He isnt here @slate swan comon help me

boreal ravine
maiden fable
#

What happened

torn panther
cold sonnet
maiden fable
#

@tight obsidian please reduce the slowmo πŸ₯Ί

boreal ravine
#

your late by 12 hours

boreal ravine
slate swan
cold sonnet
boreal ravine
cold sonnet
#

no

keen talon
tardy atlas
#

Why does sqlite3 on git reset the variable value after restarting the bot, but everything works in sublime, why?

maiden fable
maiden fable
#

@cold sonnet mind helping @drowsy thunder?

cold sonnet
#

a moment of let's go

#

don't mind

drowsy thunder
#

Any help

slate swan
cold sonnet
#

y'all are passing him to each other like a ball

maiden fable
slate swan
slate swan
maiden fable
#

Smh anyways

tardy atlas
drowsy thunder
#

@slate swan are you sure about that?

slate swan
#

@drowsy thunder what's your problem though?

maiden fable
#

@drowsy thunder do u know about events?

cold sonnet
#

okay @drowsy thunder tell your problem

maiden fable
keen talon
#

Lol

cold sonnet
slate swan
maiden fable
#

Cyaaa

slate swan
slate swan
vale sierra
#
@bot.listen('on_message')
async def on_message(message):
    if message.author == bot.user:
        return

if isinstance(message.channel, discord.DMChannel):
    guild = bot.get_guild(875771903799877683)
    channel = guild.get_channel(876553804861034496)
    await channel.send(f"> {message.author.mention} m'a mp en disant : {message.content}")
        return
``` hello, i have this error, how can i fix this please ?
boreal ravine
drowsy thunder
# slate swan <@876148445453353011> what's your problem though?

This video has the bot and I wanna make it in
https://youtu.be/APY66hYarAc

In this video I made 500+ people perform a reaction speed test in Discord, where the first place of each round would receive a prize of Discord Nitro accompanied by a special role in my server!

Thanks for watching the video!

------------LINKS BELOW------------

⇩ JOIN MY DISCORD SERVER ⇩
https://discord.gg/Sound

⇩ WATCH ANOTHER VIDEO ⇩
https...

β–Ά Play video
tardy atlas
maiden fable
slate swan
vale sierra
drowsy thunder
#

Who will help?
Whoever wants to,tell how long there coding on python
I will choose the most experienced one

slate swan
slate swan
drowsy thunder
maiden fable
cold sonnet
maiden fable
#

Actually, just use bot.wait_for, I just remembered

vale sierra
slate swan
#

!d discord.Client.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/master/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
drowsy thunder
cold sonnet
harsh stump
#

I want to code a bot like a casino, where can i start?

drowsy thunder
vale sierra
honest vessel
#

class casino:

vale sierra
#

i haven't the error but when i changed my editor (sublime text -> pycharm) this error appears@cold sonnet so maybe its this ?

drowsy thunder
#
help = "Nobody seems to help me"

print(help)
cold sonnet
#

it has to be an IDE problem, I don't see a syntax error

harsh stump
drowsy thunder
slim ibex
#

pls learn python before doing a bot

harsh stump
#

oh I meant coding bots mb

keen talon
manic wing
drowsy thunder
slim ibex
#

!d help

unkempt canyonBOT
#

help([object])```
Invoke the built-in help system. (This function is intended for interactive use.) If no argument is given, the interactive help system starts on the interpreter console. If the argument is a string, then the string is looked up as the name of a module, function, class, method, keyword, or documentation topic, and a help page is printed on the console. If the argument is any other kind of object, a help page on the object is generated.

Note that if a slash(/) appears in the parameter list of a function when invoking [`help()`](https://docs.python.org/3/library/functions.html#help "help"), it means that the parameters prior to the slash are positional-only. For more info, see [the FAQ entry on positional-only parameters](https://docs.python.org/3/faq/programming.html#faq-positional-only-arguments).

This function is added to the built-in namespace by the [`site`](https://docs.python.org/3/library/site.html#module-site "site: Module responsible for site-specific configuration.") module.
magic ore
#

@manic wing re: your issue, you can implement button cooldowns yourself

slim ibex
#

shadowing help() no good

slate swan
harsh stump
#

my head hurts from coding today so I messed up

slate swan
#

for using anything I wrote, you need to learn python.

drowsy thunder
#

Ok

drowsy thunder
harsh stump
#

I want to code a bot like a casino, where can i start? I know python but nothing about coding bots and clients

drowsy thunder
keen talon
manic wing
slate swan
boreal ravine
#
import discord

bot = discord.Client(loop=None)

@bot.event
async def on_socket_raw_receive(data):
        ...

bot.run(TOKEN)
``` `TOKEN` is not defined?
slate swan
#

with a for loop for how many times you want the reaction to be got

keen talon
harsh stump
boreal ravine
slate swan
#

😳

keen talon
unkempt canyonBOT
#
Not in a million years.

No documentation found for the requested symbol.

boreal ravine
slate swan
#

It's the current ayncio loop being used iirc

harsh stump
#

xd

slate swan
#

!d discord.Client

unkempt canyonBOT
#

class discord.Client(*, loop=None, **options)```
Represents a client connection that connects to Discord. This class is used to interact with the Discord WebSocket and API.

A number of options can be passed to the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client").
keen talon
#

What pithink

boreal ravine
cold sonnet
boreal ravine
#

yes

slate swan
#

Yea its an asyncio.AbstractEventLoop

cold sonnet
#

does the lib pass something to it after?

boreal ravine
#

yes

cold sonnet
#

it has to

slate swan
#

if it's None, library creates a new loop

boreal ravine
#

oh

#

stocker was typing awhyyy

unkempt canyonBOT
#

discord/client.py line 235

self.loop: asyncio.AbstractEventLoop = asyncio.get_event_loop() if loop is None else loop```
slate swan
#

I'd just loop or asyncio.AbstractEventLoop

drowsy thunder
cold sonnet
#

...

drowsy thunder
#

This is the basic hello world command

cold sonnet
#

no, that's not how you define a function

keen talon
cold sonnet
#

now indent ctx.reply

#

with an await too

harsh stump
#

ummm nice

manic wing
harsh stump
#
import discord as dc

client = dc.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

    if message.content.startswith('$hello'):
        await message.channel.send('Hello!')

client.run('your token here')

I found this tho idk what half of it does

cold sonnet
#

import discord as dc??

drowsy thunder
harsh stump
#

yeah

keen talon
#

Lol

cold sonnet
#

it seems so unnatural yet so right

manic wing
harsh stump
#

I got no idea why we need any of this :/

slate swan
#

how would i make it so a command could be either none or true it would be like
$create dm 1
that would do something different compared to $create dm

keen talon
drowsy thunder
harsh stump
harsh stump
cold sonnet
#

it's a thing of commands.Bot

drowsy thunder
#

@harsh stump dm me if any help needed

keen talon
cold sonnet
#

him

harsh stump
#

true

cold sonnet
#

they

harsh stump
#

im he/him

cold sonnet
#

Peter, you are confusing yourself.

keen talon
drowsy thunder
#

Ok lemonshake

cold sonnet
#

no, rather type him than them

harsh stump
#

aight back to making a discord bot

#

@client.event what does this do?

#

or should I just go and learn?

cold sonnet
#

it tells the lib that the function defined is an event

honest shoal
slate swan
#

once4thewin do you have any recent experience with python?

harsh stump
#

yup

drowsy thunder
slim ibex
harsh stump
#

I just didnt get into oop

cold sonnet
drowsy thunder
#

Huh

slim ibex
#

!d discord.Client.event

unkempt canyonBOT
#

@event```
A decorator that registers an event to listen to.

You can find more info about the events on the [documentation below](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events).

The events must be a [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine "(in Python v3.9)"), if not, [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.9)") is raised.

Example

```py
@client.event
async def on_ready():
    print('Ready!')
slate swan
# harsh stump yup

great, so you're aware of basic things like python syntax, Data types, classes/OOP and asyncio right?

slim ibex
#

decorators are not an OOP concept

cold sonnet
#

should add decorators to the list

slim ibex
#

^

dull terrace
cold sonnet
#

thanks

drowsy thunder
#

I am a bit confused of the cogs thingy

slim ibex
#

def should know OOP for dpy

#

and asyncio can be confusing so I would put some effort into that

slate swan
harsh stump
#

pogg

slate swan
cold sonnet
#

Ashley!

slate swan
#

meh!

harsh stump
#

enjoying the chat :/

cold sonnet
#

Caeden said u a dude

manic wing
#

!ot 😳

unkempt canyonBOT
cold sonnet
#

lmaoo

slate swan
#

explicit feelings

slate swan
cold sonnet
#

.

slate swan
#

smh

manic wing
#

wasnt me 😳

slate swan
#

whatever

cold sonnet
#

😳

drowsy thunder
quaint epoch
drowsy thunder
cold sonnet
#

yes

#

but it's kind of an inanswerable question

#

unanswerable

silent portal
#

How can I check if a whole Embed message has a specific word in it? Does it work with message.content?

glacial kernel
#

My bot is not assigning the roles can someone help

unkempt canyonBOT
glacial kernel
#
async def on_reaction_add(interaction):

    message = interaction.message
    button_id = interaction.component.id
    if reaction.emoji == ":white_check_mark:":
        member = message.guild.get_member(interaction.user.id)
        role = message.guild.get_role()  
        await member.add_roles(role)

        response = await interaction.respond(embed=nextcord.Embed(title="Verified"))


@bot.command()
@commands.has_permissions(administrator=True) # you need to import command from discord.ext if you want to use this -> from discord.ext import commands
async def verify(ctx):
    embed = nextcord.Embed(title="VerificaΓ§Γ£o",
    description="Clica para te verificares",
    colour=Color.orange()
    )
    embed.set_author(name="Nome", icon_url="")
    embed.add_field(name="Campo 1", value="Not an inline field!", inline=False)
    embed.add_field(name="Campo 2", value="An inline field!", inline=True)
    embed.add_field(name="Campo 3", value="Look I'm inline with field 2!", inline=True)
    embed.set_footer(text="Footer")
    embed.set_thumbnail(url="")
    
    emoji = ":white_check_mark:"

    message = await ctx.send(embed=embed)
    await message.add_reaction(emoji=emoji)```
quaint epoch
cold sonnet
silent portal
#

I think I have to loop through the whole embed title, description and fields, right?

glacial kernel
#

My bot is not assigning the roles can someone help

cold sonnet
#

πŸ‘πŸΏ

silent portal
cold sonnet
#

...

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

glacial kernel
#
@bot.command()
async def on_reaction_add(interaction):

    message = interaction.message
    button_id = interaction.component.id
    if reaction.emoji == ":white_check_mark:":
        member = message.guild.get_member(interaction.user.id)
        role = message.guild.get_role()  
        await member.add_roles(role)

        response = await interaction.respond(embed=nextcord.Embed(title="Verified"))


@bot.command()
@commands.has_permissions(administrator=True) 
async def verify(ctx):
    embed = nextcord.Embed(title="VerificaΓ§Γ£o",
    description="Clica para te verificares",
    colour=Color.orange()
    )
    embed.set_author(name="Nome", icon_url="")
    embed.add_field(name="Campo 1", value="Not an inline field!", inline=False)
    embed.add_field(name="Campo 2", value="An inline field!", inline=True)
    embed.add_field(name="Campo 3", value="Look I'm inline with field 2!", inline=True)
    embed.set_footer(text="Footer")
    embed.set_thumbnail(url="")
    
    emoji = ":white_check_mark:"

    message = await ctx.send(embed=embed)
    await message.add_reaction(emoji=emoji)
cold sonnet
slate swan
unkempt canyonBOT
slate swan
#

you might like looping thru all the fields too

keen talon
quaint epoch
slate swan
cold sonnet
#

oh wait

slate swan
#

....uh

silent portal
cold sonnet
#

why tf not just member = interaction.user

slate swan
#

nvm me

slate swan
glacial kernel
#

so I need to put

@bot.event
silent portal
#

okay ty

cold sonnet
slate swan
slate swan
#

A discord.User object

odd prawn
#

By any other name just as sweet.

slate swan
#

they get the Member object by get_member

cold sonnet
#

||nextcord's stupidity||

slate swan
#

lmao

cold sonnet
#

no interaction argument

#

take good arguments -> have member

slate swan
#

and they don't have user as an argument

quaint epoch
#

(quietly uses on_raw_reaction_add)

cold sonnet
#

much better tho

glacial kernel
#

so I put "reaction"?

cold sonnet
#

on_raw_reaction_add
is just better

#

!d discord.on_reaction_add

unkempt canyonBOT
#

discord.on_reaction_add(reaction, user)```
Called when a message has a reaction added to it. Similar to [`on_message_edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_message_edit "discord.on_message_edit"), if the message is not found in the internal message cache, then this event will not be called. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") instead.

Note

To get the [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") being reacted, access it via [`Reaction.message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Reaction.message "discord.Reaction.message").

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

Note

This doesn’t require [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") within a guild context, but due to Discord not providing updated user information in a direct message it’s required for direct messages to receive this event. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") if you need this and do not otherwise want to enable the members intent.
cold sonnet
#

take these arguments

harsh stump
#

AttributeError: module 'discord' has no attribute 'Client'
Whats wrong here?

quaint epoch
unkempt canyonBOT
#

discord.on_raw_reaction_add(payload)```
Called when a message has a reaction added. Unlike [`on_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_reaction_add "discord.on_reaction_add"), this is called regardless of the state of the internal message cache.

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

meanwhile hikari with 10+ reaction related events hmmm

harsh stump
#
import discord as d
client = d.Client()

@client.event
async def on_ready():
    print('We have logged in as {0.user}'.format(client))

client.run(TOKEN)
quaint epoch
#

!d discord.Client

unkempt canyonBOT
#

class discord.Client(*, loop=None, **options)```
Represents a client connection that connects to Discord. This class is used to interact with the Discord WebSocket and API.

A number of options can be passed to the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client").
slate swan
glacial kernel
#

The bot continues without giving the role

quaint epoch
quaint epoch
harsh stump
#

I did

slate swan
quaint epoch
harsh stump
#

windows

slate swan
#

Any Os

cold sonnet
harsh stump
#

relax 😳

slate swan
#

don't mind the ..., It's anyhow you get into the pip dir

#

I meant the upgrade flag

quaint epoch
#

events as commands lemon_grimace

glacial kernel
#

The bot continues without giving the role

cold sonnet
#

send updated code

quaint epoch
#

im on 11% battery life

harsh stump
#

so what do I do?

hoary cargo
# cold sonnet

MR_canny_meh_stage I had some respect for freecodecamp
But bruv
Replit MR_uncanny_10 and bad tutorial overall

glacial kernel
#
@bot.command()
async def on_reaction_add(interaction):

    message = interaction.message
    button_id = interaction.component.id
    if reaction.emoji == ":white_check_mark:":
        member = message.guild.get_member(interaction.user.id)
        role = message.guild.get_role()  
        await member.add_roles(role)

        response = await interaction.respond(embed=nextcord.Embed(title="Verified"))


@bot.command()
@commands.has_permissions(administrator=True) 
async def verify(ctx):
    embed = nextcord.Embed(title="VerificaΓ§Γ£o",
    description="Clica para te verificares",
    colour=Color.orange()
    )
    embed.set_author(name="Nome", icon_url="")
    embed.add_field(name="Campo 1", value="Not an inline field!", inline=False)
    embed.add_field(name="Campo 2", value="An inline field!", inline=True)
    embed.add_field(name="Campo 3", value="Look I'm inline with field 2!", inline=True)
    embed.set_footer(text="Footer")
    embed.set_thumbnail(url="")
    
    emoji = ":white_check_mark:"

    message = await ctx.send(embed=embed)
    await message.add_reaction(emoji=emoji)
cold sonnet
#

@bot.event instead of command

#

interaction replaced with reaction and user

glacial kernel
quaint epoch
cold sonnet
#

str(reaction.emoji)

quaint epoch
glacial kernel
#

In my code I have it

quaint epoch
cold sonnet
#

member = user when you have the right arguments, and there's not even a need to do that

#

so just user.add_roles(role)

harsh stump
#

can I get a discord bot tutorial?????

quaint epoch
#

and btw how is on_reaction_add passing an interaction?

quaint epoch
glacial kernel
#

I changed to reaction

quaint epoch
#

well my laptop is dead guys see you on the other side

cold sonnet
glacial kernel
cold sonnet
#

!d nextcord.on_reaction_add

unkempt canyonBOT
#

nextcord.on_reaction_add(reaction, user)```
Called when a message has a reaction added to it. Similar to [`on_message_edit()`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.on_message_edit "nextcord.on_message_edit"), if the message is not found in the internal message cache, then this event will not be called. Consider using [`on_raw_reaction_add()`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.on_raw_reaction_add "nextcord.on_raw_reaction_add") instead.

Note

To get the [`Message`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.Message "nextcord.Message") being reacted, access it via [`Reaction.message`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.Reaction.message "nextcord.Reaction.message").

This requires [`Intents.reactions`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.Intents.reactions "nextcord.Intents.reactions") to be enabled.

Note

This doesn’t require [`Intents.members`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.Intents.members "nextcord.Intents.members") within a guild context, but due to Discord not providing updated user information in a direct message it’s required for direct messages to receive this event. Consider using [`on_raw_reaction_add()`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.on_raw_reaction_add "nextcord.on_raw_reaction_add") if you need this and do not otherwise want to enable the members intent.
glacial kernel
#

ok

glacial kernel
#

I will try it

keen talon
cold sonnet
#

there'a a lot yet to replace

harsh stump
#

im crying can someone please help me

cold sonnet
keen talon
cold sonnet
#

written to fix the flaws of many other popular tutorials

#

like freecodecamp's

keen talon
cold sonnet
#

or lucas's

#

or any noob's

harsh stump
cold sonnet
#

what's nextcode

#

oh nextcord?

keen talon
harsh stump
#

The discord.py library has now been discontinued by its maintainer.

cold sonnet
#

nextcord isn't any better than any other lib

glacial kernel
#

It didnt work

keen talon
cold sonnet
#

now you have user as an argument?

#

then you could start with replacing member in member.add_roles()

#

or maybe using the better_on_reaction_add

#

called on_raw_reaction_add

#

which takes a payload arg

#

and throws the whole thing we just did away

cunning ice
#

command to mention channel ?

cold sonnet
#

!d discord.TextChannel.mention

unkempt canyonBOT
cunning ice
#

tq

harsh stump
#

(ctx: commands.Context) WHat does this mean?

cold sonnet
#

typehinting ctx

#

tells your IDE that ctx is a commands.Context instance

#

so it can recommend you attributes while typing

craggy cloak
#

How to fix this error?

WARNING: You are using pip version 21.2.4; however, version 22.0.3 is available. You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.

cold sonnet
#

or more experienced stuff

#

when making your own arguments

slate swan
#

and this is the wrong channel

unkempt canyonBOT
#

7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.

craggy cloak
#

ok srry

boreal ravine
harsh stump
#

doesnt help

boreal ravine
#

do you know what instances are..?

cold sonnet
#

you know when you write down ctx and then a .

#

if you don't typehint, the IDE doesn't recommend anything after the .

#

if you do, the IDE can recommend you stuff to write after the .

#

(IDE = text editor with extra stuff)

#

(. = .)

#

idk, I do have to currently

#

I delete them after anyways

brazen raft
cold sonnet
#

nerdy

coarse anvil
#

other people can ban eachother, how do i make it so they cant?

vocal plover
#

to set type checking to strict in vsc in setting.json you can use "python.analysis.typeCheckingMode": "strict",

coarse anvil
#

how.

vocal plover
#

thats likely the fastest way to change it

mellow barn
cunning ice
# unkempt canyon

can you tell me a example using this command
if my channel name is lets say welcome_channel (which is defined)
@cold sonnet

brazen raft
coarse anvil
cold sonnet
coarse anvil
#

look no perms

tardy atlas
#

Guys, the question is off topic, but do you know the hostings are free (it would be desirable, with git binding)

coarse anvil
brazen raft
pliant gulch
#

You can, but also depending on the converter it will also do an API call when not in cache

coarse anvil
#

ty

brazen raft
harsh stump
#
async def hello_world(ctx: commands.Context):
    await ctx.send("Hello, world!")
``` Does ctx mean anything or can it be like``` lmao: commands.Context```?
cunning ice
brazen raft
cold sonnet
#

just do the same in the description

cunning ice
brazen raft
#

But it is short for "context"

maiden fable
#

!d inspect module iirc

unkempt canyonBOT
#

Source code: Lib/inspect.py

The inspect module provides several useful functions to help get information about live objects such as modules, classes, methods, functions, tracebacks, frame objects, and code objects. For example, it can help you examine the contents of a class, retrieve the source code of a method, extract and format the argument list for a function, or get all the information you need to display a detailed traceback.

There are four main kinds of services provided by this module: type checking, getting source code, inspecting classes and functions, and examining the interpreter stack.

pliant gulch
#

Using the inspect module they look at the callbacks signature ^

#

!d inspect.signature

unkempt canyonBOT
#

inspect.signature(callable, *, follow_wrapped=True, globals=None, locals=None, eval_str=False)```
Return a [`Signature`](https://docs.python.org/3/library/inspect.html#inspect.Signature "inspect.Signature") object for the given `callable`...
maiden fable
#

Wym

pliant gulch
#

The call the callback with the dispatched args but also command and interaction have it called hard-coded

maiden fable
#

default args?

cold sonnet
#

how does context get passed to the function

maiden fable
#

Ah

#

Lemme show my spaghetti code of doing so

pliant gulch
#

E.g ```py
@bot.event
async def on_message(message: discord.Message) -> None:
...

bot.dispatch("message", discord.Message(...))
``` calls on_message(discord.Message)

maiden fable
#

andy, do I have the permission?

pliant gulch
#

And for commands it's the same way, but just hard-coded for context

#

Same with interaction callbacks

maiden fable
#

my spaghetti implementation

#

Don't kill me andy ;-;

pliant gulch
#

They directly call the callback function with the interaction/context

#

They also get the other args via converters

slate swan
unkempt canyonBOT
#

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

OrderedDict([('default', <Parameter "default">), ('arg1', <Parameter "arg1: str">), ('arg2', <Parameter "arg2: int">)])
formal basin
#

Anyone know how to make anti spam bot?

maiden fable
#

I tried to learn decorators, but well, I don't wanna share my experience πŸ˜”

spring flax
#

how do I get my bot instance from modals? inter.bot doesn't seem to workpy channel = inter.bot.get_channel(898198212022779935) AttributeError: 'Suggestion_Modal' object has no attribute 'bot

#

no

maiden fable
spring flax
#

it's a modal

manic wing
#

def wrapper takes func

maiden fable
manic wing
#

def decorator takes the args and kwargs

maiden fable
#

Oh wait, nvm I forgot idk how decos work

slate swan
slate swan
spring flax
# maiden fable mind showing the whole modal code?
    async def callback(self, inter: disnake.ModalInteraction) -> None:
        embed = disnake.Embed(title=f"A new suggestion has been submitted.", color=disnake.Color.blurple())
        embed.set_author(name=f'{str(inter.author)} has submitted a suggestion', icon_url=inter.author.avatar.url)
        for key, value in inter.text_values.items():
            embed.add_field(name=key.capitalize(), value=value, inline=False)
        embed.set_footer(text=f"Suggestion by {inter.author.name} | {inter.author.id}  {datetime.datetime.utcnow().strftime('%A at %H:%M')}")
        channel = inter.bot.get_channel(898198212022779935)
        upvote_emote = inter.bot.get_emoji(898204326483349564)
        downvote_emote = inter.bot.get_emoji(898204314449874984)
        success_embed = disnake.Embed(description='Your suggestion has been submitted!', color=disnake.Color.green())
        await inter.response.send_message(embed=success_embed, ephemeral=True)
        message = await channel.send(embed=embed)
        await message.add_reaction(upvote_emote)
        await message.add_reaction(downvote_emote)
maiden fable
formal basin
#

Anyone know how to make anti spam bot?

slate swan
maiden fable
slate swan
harsh stump
#

await waits for a user to call this function?

maiden fable
slate swan
maiden fable
#

Lmaoo

formal basin
#

Anyone know how to make anti spam bot?

slate swan
maiden fable
#

@formal basin

manic wing
#

oh you're passing it into the func

#

big blind

maiden fable
harsh stump
#

ImportError: cannot import name 'commands' from 'discord.ext' (unknown location)
whats wrong here?

formal basin
maiden fable
slate swan
maiden fable
maiden fable
harsh stump
#

idk, how do I do it?

gaunt ice
#

i wanna make a stop spam cmd but i have no idea how to , like in the middle of spamming, when i give a cmd the spam shud stop

slate swan
slate swan
unkempt canyonBOT
#

Cooldowns in discord.py

Cooldowns can be used in discord.py to rate-limit. In this example, we're using it in an on_message.

from discord.ext import commands

message_cooldown = commands.CooldownMapping.from_cooldown(1.0, 60.0, commands.BucketType.user)

@bot.event
async def on_message(message):
    bucket = message_cooldown.get_bucket(message)
    retry_after = bucket.update_rate_limit()
    if retry_after:
        await message.channel.send(f"Slow down! Try again in {retry_after} seconds.")
    else:
        await message.channel.send("Not ratelimited!")

from_cooldown takes the amount of update_rate_limit()s needed to trigger the cooldown, the time in which the cooldown is triggered, and a BucketType.

maiden fable
manic wing
#

!e ```py
import inspect

def decorator(default, arg1, arg2):
print(default, arg1, arg2)
def wrapper(func):
print(func)
return func

return wrapper
#to make the not decorator callable you wouldnt return wrapper here

eg the difference between bot.listen() and bot.event

@decorator('hi', 1, 2)
def myfunc():
pass```

unkempt canyonBOT
#

@manic wing :white_check_mark: Your eval job has completed with return code 0.

001 | hi 1 2
002 | <function myfunc at 0x7fb8d186b370>
slate swan
#

Utilise this

slate swan
manic wing
#

is this what you mean? you pass func into the wrapper

gaunt ice
#

like in the middle of a spam cmd

#

i want it to break when i fire up a certain cmd

kindred epoch
gaunt ice
#

reptile i am working on the fun cmds but i hav exams now

maiden fable
#

stop messing with my brain please πŸ˜”

manic wing
#

well first you would remove the def wrapper because you'e not calling the decorator hence you dont need it

gaunt ice
manic wing
#

no, it would be like ```py
def decorator(func):
print(inspect.signature(func).parameters)

#

you dont need the inner function

#

but anyway

harsh stump
#

ImportError: cannot import name 'commands' from 'discord.ext' (unknown location) I keep getting this error, how do i fix it?

maiden fable
#

u didn't return func

manic wing
#

thats cus you're not returning func

unkempt canyonBOT
#

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

001 | hello
002 | world
003 | world
manic wing
#

see

#

ill go print dir on func and let you know

#

did you just say python was unpythonic

unkempt canyonBOT
#

discord/client.py line 1077

def event(self, coro: Coro) -> Coro:```
maiden fable
#

What is even happening here lol

manic wing
#

when you dont call the decorator you dont need an inner func

maiden fable
manic wing
#

reptile make a help channel and we can talk there, we're spammign discord-bots

harsh stump
#

yes

kindred epoch
#

reinstall it and try then

maiden fable
kindred epoch
maiden fable
#

Was gonna link u to the replit discord server πŸ˜”

harsh stump
kindred epoch
#

show ur imports

harsh stump
#
import discord
import random as r
from discord.ext import commands
kindred epoch
#

uh

charred sleet
#
    return Complex(((self.a * self.b) - (obj.a - obj.b)) + ((self.b*obj.b)+(self.b*obj.a)))
TypeError: Complex.__init__() missing 1 required positional argument: 'b'```
#

why would i get this error even though I have mentioned a and b alongside self in __init__ ?

harsh stump
#

whats that

kindred epoch
#

ok nvm

#

yea idk why thats happening

maiden fable
formal basin
formal basin
formal basin
cerulean olive
#

Could anyone send me a discord bot template ( py version 8.9

maiden fable
#

@cerulean olive bro u from the future or what

harsh stump
cerulean olive
#

Nah I just need a simple bot template I am lazy 2 do all the shitty little setting up

maiden fable
slow fog
cerulean olive
#

I said 8.9?

#

Oh i did

formal basin
slow fog
#

sus

cerulean olive
sweet tiger
#

how do i save cooldowns in a file
so that they dont reset everytime i restart the bot
i tried searching online
and found this

#
cooldown_info_path = "./cooler.pkl"
class Bot(commands.Bot):

    async def start(self, *args, **kwargs):
        if os.path.exists(cooldown_info_path):
            with open(cooldown_info_path, 'rb') as f:
                d = pickle.load(f)
                for name, func in self.commands.items():
                    if name in d:
                        self.commands[name]._buckets = d[name]
        return await super().start(*args, **kwargs)

    async def logout(self):
        with open(cooldown_info_path, 'wb') as f:
            pickle.dump({name: func._buckets for name, func in self.commands.items()}, f)
        return await super().logout()
#
pickle.dump({name: func._buckets for name, func in self.commands.items()}, f)
AttributeError: 'set' object has no attribute 'items'
#

it gives out this error. not sure if you can save cooldowns lol

kindred epoch
#

you know you can just save them in a db

maiden fable
sweet tiger
#

but how do i access them

formal basin
#

When I spam nothing happens

sweet tiger
maiden fable
unkempt canyonBOT
sweet tiger
maiden fable
sweet tiger
#

like when i restart the bot, all the cooldowns just go away

maiden fable
#

!d discord.ext.commands.Command.is_on_cooldown

unkempt canyonBOT
sweet tiger
final iron
#

Use a database

sweet tiger
sweet tiger
# final iron Idk what you're doing

look. when you shutdown the bot and restart it, all the cooldowns go away. i have commands with 5 days of cooldown. so i need to save these cooldowns in a file so that i can reload these cooldowns and they remain the same when i restart my bot

final iron
#

Yeah so use a database

sweet tiger
#

wow

#

dumbass

final iron
#

?

maiden fable
#

lmao

final iron
#

Tell me why a database wouldn't work

#

And he left

#

@sweet tiger

#

He left the server lmao

maiden fable
#

What the πŸ˜”

slate swan
#

I have cog files in a commands directory

I want to retrieve all of those classes' docstrings dynamically without having to specify each file's name. How to do it?

manic wing
manic wing
#

oh misread that but its the same thing

maiden fable
#

Hahaha

manic wing
#

for cog in bot.cogs: print(bot.cogs[cog].doc)

slate swan
manic wing
#

self.xyz = 123

slate swan
#

oh sweet

#

I'll just add a help_string then since __doc__ returns repr

slate swan
#

@manic wing thanks mate lollyheartlove mwah

slate swan
maiden fable
#

You won't

manic wing
slate swan
#

ah okay then

manic wing
#

api calls are awaited

#

like await fetch_user

plain perch
#

One message removed from a suspended account.

spring flax
unkempt canyonBOT
#

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

Deletes the message.

Your own messages could be deleted without any proper permissions. However to delete other people’s messages, you need the [`manage_messages`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.manage_messages "disnake.Permissions.manage_messages") permission.

Changed in version 1.1: Added the new `delay` keyword-only parameter.
manic wing
#

well

#

if you want your message to be deleted after every command you can make an after_invoke and delete it there

slate swan
formal basin
slate swan
#

read that embed again and see what you are missing

formal basin
#

Ok

formal basin
manic wing
#

@spring flax hows the hunai rewrite going?

plain perch
#

One message removed from a suspended account.

manic wing
plain perch
#

One message removed from a suspended account.

manic wing
#

what

#

await ctx.message.delete()

formal basin
dry kelp
#

in postgreSQL
the prefix
what should i set it to?

#

@final iron this better hah?

plain perch
final iron
slate swan
# formal basin

message_cooldown = commands.CooldownMapping.from_cooldown(1.0, 60.0, commands.BucketType.user)

dry kelp
#

changing to postgreSQL

plain perch
final iron
#

Cool

manic wing
maiden fable
#

Oh @dry kelp you here πŸ‘€

slate swan
#

thats an example code of how you would do that

#

not just a copy paste and "here im ready to control spams in your server, sir"

slate swan
#

you could do any action you want

dry kelp
#

i just tryna find out how to pull objects from this mf sql πŸ˜‚

slate swan
#

SELECT * FROM <table> WHERE condition

#

ssshhhhh ? place holder is for sqlite, not pgsql

dry kelp
#

ah

#

then what should it be....

#

it should get the wait.. omfg cooldown

#

this is a set prefix command yk

slate swan
#

may i know what library are you using? asyncpg?

dry kelp
formal basin
dry kelp
#

oh asyncpg

slate swan
dry kelp
#

???

slate swan
#

"SELECT * FROM <table> WHERE guild_id = $1", guild.id

final iron
slate swan
#

this example in the docs

dry kelp
#

lemme send my code in a myst

slate swan
dry kelp
slate swan
#

await spooky.pg_con.fetchrow("SELECT * FROM Prefix WHERE guild_id = $1", ctx.guild.id)

dry kelp
#

but guild_id is not = with $1

#

it's null

slate swan
#

did you learn sql ?

dry kelp
#

that's what im trying to do rn

#

ik that guild_id is null here

slate swan
dry kelp
slate swan
#

uh honestly no idea why is this happening

#

worked decent few hrs ago

manic wing
#

ayo

#

why cant you copy bot tokens

#

tf

slate swan
#

can i ask for help hwre

slate swan
# manic wing tf

ask that in discord developers server you will get the answer there

slate swan
slate swan
#

you cannot have that character in python

#

but what character

#

the red dots

#

i cant get rid of them

#

erase it..

#

i literally cant

#

refresh your tab

quaint epoch
#

im back

formal basin
#

The bot isn’t doing anything

slate swan
#

i fixed the oroblem

manic wing
#

what kind of methods/solutions are you guys hoping would be implemented into discord.py or forks?

torn sail
#

in discord.py i think its coming but app commands in cogs without having to manually add them to tree

#

or use a group like a cog

edgy osprey
#

What happened to my bot?

manic wing
#

lol

#

ratelimited

#

dont use replit

torn sail
#

thats what happens when u use replit

edgy osprey
#

And what should I do now?

tawdry perch
#

Replit for discord bots πŸ˜”

wispy spade
sick birch
wispy spade
#

even better is to migate to something else

sick birch
#

Use a full-fledged editor such as VScode, pycharm, emacs, etc

edgy osprey
wispy spade
sick birch
#

If you're using replit nothing you can do about it but wait 10-15 minutes every time it happens, and it will happen a lot

sick birch
edgy osprey
sick birch
#

Nope

#

You're running the discord bots from replit's underpowered machines

wispy spade
sick birch
#

You using a vpn would still send requests from replit's machines

#

Wouldn't change anything

#

The easiest and best way would be to not use replit and switch to something better

slate swan
#

use kill 1 in shell and ip resets

wispy spade
# wispy spade In this case, nope.

best solution again is to migrate to a proper VPS, or if you can't do that, migrate to something like Heroku. While Heroku has its own share of problems (one being that it isn't designed for Discord bots), you won't get ratelimited every 10 seconds.

maiden fable
#

Do I see Robin? πŸ‘€

vocal plover
#

plus loads of VPN IPs are banned by discord because it turns out people who abuse the platform use VPNs too

edgy osprey
manic wing
#

any features you guys are looking to be implemented? 😩

sick birch
wispy spade
#

Not in the future, it's simply not suitable for it.

sick birch
#

And they have always been overloaded since the machines are extremely underpowered

#

They weren't designed to host full fledged apps that are up 24/7, they were only meant to run the one-off small code snippet that you just wanted to check if it works but were too lazy to load up an actual IDE

slate swan
#

but i dont think discord api would ever allow that

wispy spade
vocal plover
#

wont be implemented, too big of a privacy issue

sick birch
#

If you want an actual host, look into AWS, google cloud services, or microsoft azure, they're all excellent and are used in the industry a lot

wispy spade
slate swan
#

yeahh, would be the same scenario as the message intents

vocal plover
#

GCP has an always free tier you can use (f1 micros iirc?)

wispy spade
sick birch
#

Yeah many do, I know for a fact AWS has a free tier but it's not always free, 700 hours/month for 12 months on t2.micro instances

#

For small discord bots GCP or AWS free tier will more than suffice

vocal plover
#

Oracle cloud gives you quite a lot always free on ARM archs, but that comes with supporting oracle which is ehhhh

sick birch
#

And due to their architecture if your bot starts growing and you need more resources, they make it incredibly easy to scale your app

edgy osprey
#

Okay, we'll have to put up with it and switch to heroku and github

vocal plover
#

heroku is equally as bad as replit

sick birch
#

Heroku isn't much better than replit either

slate swan
#

Hey, I am trying to check if someone has pinged a user from a list in a json file. Is this the correct way to do it?

        @commands.Cog.listener()
        async def on_message(self,message):
            with open("nopinglist.json") as f:
                    data = json.load(f)
            
            no_ping_list = data["no-ping-list"]

            if no_ping_list in message.content:
vocal plover
#

neither are made for always-on apps like discord bots

vocal snow
#

the 300$ of azure credits from gh edu pack have been working nicely for me

sick birch
#

Why not use vscode/pycharm?

unkempt canyonBOT
#

The message that this message references. This is only applicable to messages of type MessageType.pins_add, crossposted messages created by a followed channel integration, or message replies.

New in version 1.5.

edgy osprey
sick birch
#

(Assuming you're using replit for the IDE and not the "free hosting")

manic wing
#

can you not do await message.edit(suppress=True)?

#

i thought that suppressed the emebds

sick birch
slate swan
unkempt canyonBOT
#
Certainly not.

No documentation found for the requested symbol.

slate swan
#

!d discord.Message.mentions

unkempt canyonBOT
#

A list of Member that were mentioned. If the message is in a private message then the list will be of User instead. For messages that are not of type MessageType.default, this array can be used to aid in system messages. For more information, see system_content.

Warning

The order of the mentions list is not in any particular order so you should not rely on it. This is a Discord limitation, not one with the library.

manic wing
#

how do you remove the embeds from a message?

sick birch
manic wing
slate swan
manic wing
#

https://github.com/ when you send this link it autoshows the embed

GitHub

GitHub is where over 73 million developers shape the future of software, together. Contribute to the open source community, manage your Git repositories, review code like a pro, track bugs and feat...

slate swan
#

supress will do the thing, but there embed means all the attachments

manic wing
sick birch
#

<link>

manic wing
#

when i do await message.edit(suppress=True) it doesnt remove the embed

sick birch
#

oh you mean that

manic wing
manic wing
slate swan
#

didnt you want to send the message with no embeds?

#

oh, for other users

slate swan
unkempt canyonBOT
#
I'm sorry Dave, I'm afraid I can't do that.

No documentation found for the requested symbol.

sick birch
#
@tree.context_menu(name='Info', guild=test_guild)
async def info(interaction: discord.Interaction, member: discord.Member):
    embed = get_member_info_embed(member)
    await interaction.response.send_message(embed=embed, ephemeral=True)

anyone know why this won't work D:

karmic totem
slate swan
karmic totem
final iron
#

Using json as a database πŸ—Ώ

slate swan
sick birch
manic wing
#

why tf is suppress not working

stray solar
#

I tried to print Korean language on my bot discord but its printing invalid character someone have an issue ?

slate swan
#

depends on your system, not a python limitation

stray solar
#

So i can use utf-8 ?

slate swan
#

!e print("이봐")

unkempt canyonBOT
#

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

이봐
stray solar
#

Cant*

slate swan
#

see, it works

stray solar
#

Ah

#

I get that

slate swan
#

in your console/terminal right?

stray solar
#

Yea

slate swan
#

some systems dont support languages until you download them

stray solar
#

So how i can make them support

sick birch
#

!e

myList = [1, 2, 2, 3, 3, 4, 4, 5, 5]
print(set(myList))
unkempt canyonBOT
#

@sick birch :white_check_mark: Your eval job has completed with return code 0.

{1, 2, 3, 4, 5}
final iron
#

What even is set()

sick birch
#

!e

# intersection
x = {1, 2, 3}
y = {2, 3, 4}
print(x.intersection(y))
unkempt canyonBOT
#

@sick birch :white_check_mark: Your eval job has completed with return code 0.

{2, 3}
final iron
#

!d set

unkempt canyonBOT
#
set

class set([iterable])``````py

class frozenset([iterable])```
Return a new set or frozenset object whose elements are taken from *iterable*. The elements of a set must be [hashable](https://docs.python.org/3/glossary.html#term-hashable). To represent sets of sets, the inner sets must be [`frozenset`](https://docs.python.org/3/library/stdtypes.html#frozenset "frozenset") objects. If *iterable* is not specified, a new empty set is returned.

Sets can be created by several means:

β€’ Use a comma-separated list of elements within braces: `{'jack', 'sjoerd'}`

β€’ Use a set comprehension: `{c for c in 'abracadabra' if c not in 'abc'}`

β€’ Use the type constructor: `set()`, `set('foobar')`, `set(['a', 'b', 'foo'])`...
final iron
#

Yeah I don't understand

sick birch
sick birch
#

!e

x = {1, 2, 2, 3}
print(x)
unkempt canyonBOT
#

@sick birch :white_check_mark: Your eval job has completed with return code 0.

{1, 2, 3}
sick birch
#

removes all duplicates if there are any

final iron
#

Why are the curly braces?

sick birch
#

that's the syntax for a set

final iron
#

Oh

sick birch
#

[] for list
{} for set

slate swan
sick birch
#

sets also have special methods like intersection, union, difference

final iron
#

!e

print(type({1, 2}))
unkempt canyonBOT
#

@final iron :white_check_mark: Your eval job has completed with return code 0.

<class 'set'>
final iron
#

Cool

sick birch
#

Well ok I guess you can but it won't give you what you expect

quaint epoch
#

how do i get a guilds picture?

sick birch
#

You need to take the intersection between the set(message.mentions) and no_ping_list

quaint epoch
#

like disnake.Guild.icon ?

#

like the icon_url/avatar for the guild

final iron
#

!d discord.Guild.icon

unkempt canyonBOT
#

property icon: Optional[discord.asset.Asset]```
Returns the guild’s icon asset, if available.
final iron
#

This returns an Asset object

#

You can get the asset url with

#

!d discord.Asset.url

unkempt canyonBOT
final iron
#

@quaint epoch

quaint epoch
slate swan
quaint epoch
#

but thanks

sick birch
unkempt canyonBOT
#

@sick birch :white_check_mark: Your eval job has completed with return code 0.

{2, 3}
sick birch
#

intersection returns what 2 sets have in common

#

In this case both sets had 2 and 3 in common

slate swan
#

ah ok

vocal plover
#

there's also a shorthand for it which is just &, i.e. {1, 2, 3} & {2, 3, 4}

sick birch
#

Oh really? Didn't know that πŸ‘€

vocal plover
#

union is |

sick birch
#

In that case, just do set(message.mentions) & set(no_ping_list)

slate swan
sick birch
#

Actually you'd probably want to map it to IDs but my point still stands

vocal plover
#

it's basically the same as bitwise stuff, {1} ^ {1, 2} == {2}

sick birch
#

Oh yeah, Java has the single operands for bitwise, double for boolean operators so that makes sense

vocal plover
#

well, same kinda concept but on different things

sick birch
#

and you'll also want to parse the string to an integer as it'll probably be a string in the json

sick birch
#

Okay, then parse it and set() it to get the set

slate swan
#
{"no-ping-list":[950068134503678013,950068134503678013]}
sick birch
#

Oh it's already an int

#

Don't have to parse it then, just set()

slate swan
stray solar
slate swan
#

yea...

slate swan
stray solar
#

Nothing happened..

sick birch
#
set(map(lambda m: m.id, message.mentions))
slate swan
#

Ok now how do I more do more if they have mentioned a user in the no-ping-list?

sick birch
#

Check for truthy/falsy value of the intersection

#

truthy value - user in the no ping list was pinged
falsy value - user in the no ping list was not pinged

quaint epoch
#

how do i get a list of all of the actions that have occurred in a guilds audit log?

#

like, all of the entries?

manic wing
mellow gulch
#

oi what fork is the best fork that uses the discord namespace

mellow gulch
#

which one has the buttons implemented into it

#

there are also those

manic wing
mellow gulch
#

but that one doesnt have buttons

stray solar
#

Why the life hate me

sick birch
#

it has most if not all of the new features

mellow gulch
#

oh

formal basin
manic wing
#

anyone got any features they want discord.py & forks to implement? 😩

formal basin
placid escarp
#

Is there any way, i can make a command in another file without cogs?

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

placid escarp
manic wing
#

you just do ```py
import discord
from discord.ext import commands

@commands.command()
async def command(ctx: commands.Context):
...
``` and then import that into your main file and do bot.add_command(command)

slate swan
#

each level of indentation can be 2 or 4 spaces mostly 4 to follow pep8 or some editors do it by default

slim ibex
#

so whos changed back over to dpy here?

manic wing
slate swan
sick birch
#
mentioned_set = set(map(lambda m: m.id, message.mentions))

with open(...) as f:
  no_ping_list = ...

no_ping_set = set(no_ping_list)

if mentioned_set & no_ping_set:
  # do something if they were pinged
else: 
  # do something else, or just ignore 
sick birch
#

Does that work for 2 sets?

#

!e

print({1, 2, 3} and {2, 3, 4})
unkempt canyonBOT
#

@sick birch :white_check_mark: Your eval job has completed with return code 0.

{2, 3, 4}
sick birch
#

Hm that's not what we're looking for

manic wing
#

sets are useless

slate swan
#

So like this?

            mentioned_set = set(map(lambda m: m.id, message.mentions))

            with open("nopinglist.json") as f:
                no_ping_list = data["no-ping-list"]
            
            no_ping_set = set(no_ping_list)

            if mentioned_set and no_ping_set:
                await message.delete()
            else:
                pass
#

whats the issue though?

slate swan
#

sets are used to remove duplicates from a list so theyre good ngl

manic wing
slate swan
#

and frozen sets

slate swan
slate swan
#

oh ok

slate swan
sick birch
#

and if you're just going to do else: pass just leave it out

slate swan
#

aka ive never used it lol

sick birch
unkempt canyonBOT
#

@sick birch :white_check_mark: Your eval job has completed with return code 0.

{2, 3}
slate swan
#

pretty nice