#discord-bots

1 messages · Page 1145 of 1

slate swan
#

i prefer tanjun now tho

vocal snow
#

Wtf

fresh notch
dusky pine
#

Why not just go ahead and write a bot in Rust 😎

#

Because Rust is fast and memory safe and like yeah rust cool yk

slate swan
slate swan
#

sad javascript noises

fresh notch
#

i forgot to add the thing for the second on_message

slate swan
#

js pepeShy

dusky pine
slate swan
#

jl 🙏

#

imagine using jl

#

i'll use anything thats not javascript

dusky pine
#

TypeScript?

#

no no, CoffeeScript

dusky pine
#

How about compile Nim to JS

slate swan
slate swan
vocal snow
dusky pine
slate swan
shrewd apex
slate swan
vocal snow
#

Like Nova 💀

dusky pine
#

Ash isn't even in the Code Jam cool club

slate swan
#

both can be related to No Sleep and unclear errors

slate swan
shrewd apex
slate swan
slate swan
#

!ot

#

HA

slate swan
shrewd apex
#

too much maths

slate swan
#

Ok im making a paginator

dusky pine
#

2+2 is 4, minus 1 is 3 quick mafs

#

ext.pages

slate swan
slate swan
dusky pine
unkempt canyonBOT
#

@dusky pine :white_check_mark: Your eval job has completed with return code 0.

3
slate swan
slate swan
#

Guys I’m considering coding a bot in djs what are the pros and cons of using djs compared to dpy

paper sluice
#

cons - its js

dusky pine
#

pros - you get to use TypeScript

slate swan
#

What’s good about ts

slate swan
dusky pine
slate swan
#

Oh I see

dusky pine
#

and a transpiler that allows you to use newer features

slate swan
#

What would be better if I wanted to make a rpg game bot

#

With gifs in embeds

#

whatever language you;re comfortable with

dusky pine
#

write your bot in Rust.

slate swan
#

both cover the same API

vocal snow
dusky pine
#

rust is the way to go

slate swan
#

serenity ❤️

dusky pine
#

rust is life

slate swan
#

just dont create the bot at this point...

#

use botghosts ez

vocal snow
dusky pine
slate swan
#

epicRPG exists anyways soooooo

dusky pine
#

Don't you ever say the b word again

slate swan
#

b

slate swan
paper sluice
#

rust lemon_hyperpleased

slate swan
slate swan
vocal snow
#

color theory is so fascinating

slate swan
#

🗿

#

Something fun.. for a beginner.

#

Should of mentioned that at the start, my bad

paper sluice
#

!kindle

unkempt canyonBOT
#

Kindling Projects

The Kindling projects page on Ned Batchelder's website contains a list of projects and ideas programmers can tackle to build their skills and knowledge.

slate swan
#

Guess I should try out automating the boring things

#

try codewars

slate swan
slate swan
#

If it’s not “ Make a sorting algorithm with a data blah blah blah “ I’ll give it a shot

slate swan
#

Is it a website

#

nah they'll provide you with "what to do" with "what steps" and you'll be writing code for that

slate swan
#

Ty I’ll give it a try

#
 @commands.Cog.listener()
    async def on_presence_update(self, before, after):
        if before.activity != after.activity:
                print("runned this")
                with open("setup.json", "r") as log:
                    db = json.load(log)
                    log_channel = bot.get_channel(db['bot']['modules']['log_system']['channel_id'])
                    if before.activity == None:
                        embed = discord.Embed(title="New Status",
                                            description=f"{after.name} has created new status!\n`status`: {after.activity}")
                        embed.set_thumbnail(url=after.avatar.url)
                        embed.set_footer(text=f"user id: {after.id}")
                        await log_channel.send(embed=embed)
                    elif after.activity == None:
                        embed = discord.Embed(title="Status Update",
                                            description=f"{after.name} has removed their status")
                        embed.set_thumbnail(url=after.avatar.url)
                        embed.set_footer(text=f"user id: {after.id}")
                        await log_channel.send(embed=embed)
                    else:
                        embed = discord.Embed(title="Status Update",
                                            description=f"{after.name} has updated their status \nfrom:\n `{before.activity}`\nto:\n{after.activity}")
                        embed.set_thumbnail(url=after.avatar.url)
                        embed.set_footer(text=f"user id: {after.id}")
                        await log_channel.send(embed=embed)```

it is working fine as expected to send message on member status updates
but it is sending duplicate 2 messages with same content
i'm in `2.0.0b7`
slate swan
shrewd apex
slate swan
#

what the heck has happened

slate swan
paper sluice
gusty shard
#

how to make a command usable with two names

#

i mean

slate swan
gusty shard
#

how to make !work and !w do the same thing

#

on one function

slate swan
slate swan
slate swan
unkempt canyonBOT
paper sluice
slate swan
paper sluice
#

cringe

slate swan
#

https://paste.pythondiscord.com/ocenojawix So I have returned 😦 was hoping I would need to but yeh,

OK, so I have pretty muhc got my reaction embed nailed down everything works, if a throw out the command !embed the bot posts it and reacts to it, but when I get my test user account to react to the embed, its not able to get any roles..... All intents is set as well as the bot have full admin. No errors or tracebacks being made when reacting to the post, so I can online assume somewhere in the where True block, I am doing something wrong, if any could assist I would much appreciate it.

#

im so confused making paginator

slate swan
paper sluice
paper sluice
dim ruinBOT
#
Command not found

Command "me" is not found

paper sluice
#

no, nvm

#

i meant to reference you

#

anyways

slate swan
#

i would referenced you but i have ownership over you 😳

#

because capybaras rule the world hence the ownership

slate swan
paper sluice
slate swan
#

sparkygrump

slate swan
slate swan
#

of what

#

oh

#

non nitro flex

#

i dont know what the hell paginator im making

dull knot
#

Guys got any reference materials(links) for Embeds? I'm using disnake

slate swan
#

!d disnake.Embed

unkempt canyonBOT
#

class disnake.Embed(*, title=None, type='rich', description=None, url=None, timestamp=None, colour=..., color=...)```
Represents a Discord embed.

len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.

bool(b) Returns whether the embed has any data set.

New in version 2.0.

Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.10)") except using dotted access, e.g. `embed.author.icon_url`.

For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") are implicitly cast to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") for you.
dull knot
#

Much appreciated

slate swan
#

u can send embeds by

#
em = disnake.Embed(title="hi")
await channel.send(emebed=em)
dull knot
#

How about if I'm using an event decorator?

slate swan
#

which event ur using

dull knot
#

@bot.listen()

slate swan
#

ye but which one

#

like on_message

gusty shard
#
@bot.event
async def on_message(message):
    if message.content.startswith('$greet'):
        channel = message.channel
        await channel.send('Say hello!')

        def check(m):
            return message.author.id == m.author.id and message.channel == m.channel and m.content == 'hello'

        msg = await bot.wait_for('message', check=check)
        await channel.send(f'Hello {msg.author}!')```
i want to add a specified time to that command
dull knot
#

On member join

gusty shard
#

if user does not sends hello in 5 sec

#

bot will cancel the command

#

how can i code that?

slate swan
#

!d discord.on_member_join

unkempt canyonBOT
#

discord.on_member_join(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") joins a [`Guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild "discord.Guild").

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

i mean

#

member.guild

#

will give the guild

#

the member joined

#

and

#

!d discord.Guild.channels

unkempt canyonBOT
paper sluice
slate swan
#

return the list of channels

#

if u have a specif id u can check it

#

and send

dull knot
#

Still a bit lost so I'll just save the conversation link for now lolh_MyBad

slate swan
#

use .bm while reply

gusty shard
slate swan
#

on that link

slate swan
#

like this

dull knot
#

Ahh

slate swan
#

it saves

dull knot
#

I just copied msg link lol

#

Anyways, thx!

slate swan
#

👍

dull knot
#

Will try rereading these later

slate swan
#

okay

gusty shard
#
commands.cooldown(1,10,commands.BucketType.user)
@bot.command(aliases=['w'])
async def work(message):
    id = str(message.author.id)
    if id in data:
        gain = random.randint(10, 50)
        num1 = random.randint(50, 100)
        num2 = random.randint(50, 100)
        ans = num1 + num2
        channel = message.channel
        await channel.send(f'answer in 10sec,\n\n`{num1} + {num2} = ?`')

        def check(m):
            return message.author.id == m.author.id and message.channel == m.channel and m.content == str(ans)

        msg = await bot.wait_for('message', check=check, timeout=10)
        await channel.send(f"{message.atuhor.name } gained {gain}$")
        with open("values.json", "w") as f:
            data[id]['cash'] += gain
            json.dump(data,f,indent=4)
    else:
        await message.reply("You dont have an account yet.")
@work.error
async def work_error(ctx, error):
    if isinstance(error, commands.CommandOnCooldown):
        await ctx.reply('wait `{e:.1f}` seconds'.format(e = error.retry_after))```
#

bots not responding when user answers

#

can soembdoy help me pleasae?

flat solstice
#

I've always been curious, what does an actual 'rate limit' msg from discord look like? Ik there's a few different types but I'm just looking for a brief overview

slate swan
tidal hawk
#

Is there any way to get information about user joined guilds without Oauth2? If not can I somehow get information to my py bot without the another page?

slate swan
#

No, you can only get mutual servers without Oauth2

slate swan
# slate swan https://paste.pythondiscord.com/ocenojawix So I have returned 😦 was hoping I wo...

Pretty much stuck on this now, I know Ryuga did mention I was going wrong here; user == reaction.message.id == msg.id but I am not sure what I should be changing it with, google while decent has showing examples different to what I have built. What should I be looking at in order to allow people to receive the roles once reacting to the embed message?

I have tried changing the user part to ctx to no avail. My coding skills aren't the greatest, thank you in advance 🙂

#
@client.command()
@commands.cooldown(1, 45, commands.BucketType.user)
async def hunt(ctx):
  await open_account(ctx.author,ctx)

  users = await get_bank_data()

  bag = users[str(ctx.author.id)]["bag"]

  earn = random.randrange(500)

  if "Sniper" in bag:
    e = discord.Embed(description=f"All that time spent in the woods you found nothing.",color=discord.Colour.dark_theme())
    e1 = discord.Embed(description=f"While going through the woods you killed a deer and sold it for {earn}", color=discord.Colour.dark_theme())
    e2 = discord.Embed(description=f"Going through the open field you killed a rabbit and ate it... you get nothing-", color=discord.Colour.dark_theme())
    e3 = discord.Embed(description=f"you gave up on hunting but, someone gave you {earn} just because you tried.",color = discord.Colour.dark_theme())
    e4 = discord.Embed(description=f"You killed a worm and sold it for {earn} maybe it's worth alot.",color=discord.Colour.dark_theme())

    list23 = [e,
              e1,
              e2,
              e3,
              e4]

    await ctx.send(embed=random.choice(list23))

    users[str(ctx.author.id)]["wallet"] += earn

    with open("mainbank.json", 'w') as f:
      json.dump(users,f)
``` no errors
no response sent by the bot
#

dead channel lemon_eyes

#

People offer help for free, patience.

supple thorn
#

Almost all of your code is inside the if statement

#

You can print the bag and check what it really is

#

Usually the json is different from what someone expects it to be

#

Also use a database

slate swan
robust fulcrum
#

Guys can anyone help me i wana make a bookmark comand like @lament depot can anyone tell any good way to make it?

vale wing
#

What does that command do

slate swan
#

if you reply to a message with .bm it sends the message to your dms

#

.bm message_id/message_url does the same

robust fulcrum
#

Any good way to make?

slate swan
#

you have been told about that yesterday, is there something specific that you dont understand navi?

robust fulcrum
#

Or reaction add event

slate swan
#

wait_for

robust fulcrum
#

Oh k

slate swan
#

try making the command without that reaction thing first

robust fulcrum
slate swan
#

so if someone replies the message with .bm, it gets sent to their dms

slate swan
slate swan
slate swan
slate swan
slate swan
slate swan
#
CSGO = discord.utils.get(ctx.guild.roles, id=780182144747569193)
#
  1. you should be using ctx.guild.get_role(id) instead
forest oyster
#

hey, i downloaded all the discord libraries but there is an error with missing imports

slate swan
#
WF = discord.utils.get(ctx.server.roles, id=780244861130768395)
``` 1st point is still valid, and ctx.`server` is not a thing, its ctx.guild that you used earlier
slate swan
#

or any fork/lib you're using

#

not all of them

forest oyster
#

ok

slate swan
#

I thought server was wrong, but it was more just trying to test until something was working, but thank you for your help/advice, I'll go research more now 🙂 ❤️

slate swan
#

or code editor

#

Visual Studio

silk fulcrum
#

PyCharm is good too

sweet geyser
#

Actually i would've chosen atom

cloud dawn
#

Either Atom, VSCode or Pycharm are great options.

slate swan
# slate swan Visual Studio

great, i'll suggest you to typehint stuff, like ctx there is a commands.Context object so if you would do py async def embed(ctx: commands.Context): you will get a list of all attributes of ctx when you type ctx., that saves you from a lot of mistakes

sweet geyser
#

Also i use Codium

slate swan
#

I have used Atom, not to bad, but more familiar with VS Code due to work (ansible/terraform) so its just something I can use without issues 🙂

sweet geyser
slate swan
cloud dawn
#

VSCode is more general, it isn't great at a certain thing but rather average across all languages.

sweet geyser
#

Certainly worse in java

slate swan
#

i use vscode for py and rust and kotlin (while learning), didnt face any issue

silk fulcrum
silk fulcrum
slate swan
#

Intellij IDEA

sweet geyser
#

I hate proprietary stuff

#

So i would like to find a open-sourced code editor that has features like terminal and appearance options like having a image in the background and stuff

swift pumice
slate swan
sweet geyser
#

I use codium though a MIT licensed build of VScode

#

VScode is also opensourced

#

But it's a microsoft's thing and i hate using microsoft's stuff

#

Hopefully they don't buy discord

slate swan
#

github :V

sick birch
#

Emacs?

robust fulcrum
#

How to get link of message?

slate swan
#

i just use vscode in github codespaces

sick birch
#

It works for all of your use cases. At least in the context of a windows manager on Linux

sweet geyser
robust fulcrum
sweet geyser
robust fulcrum
#

Mac?

sweet geyser
#

Nahh

sick birch
#

Mm personally don’t like display managers

sweet geyser
sick birch
#

Looks good though

robust fulcrum
sweet geyser
slate swan
#

i use xfce with defaults ;-;

sick birch
#

I meant to say desktop environment. Don’t know why I said “display manager” lmao

sweet geyser
#

Just edit the gtk.css in .config/gtk-3.0/gtk.css add

.xfce4-panel { border-radius: 15px; }
#

To get the rounded corners

cloud dawn
#

Ew rounded corners

slate swan
sweet geyser
#

Make sure to add a transparent separator at the end and the start

slate swan
#

what distro is that?

sweet geyser
#

Lemme send it

cloud dawn
#

Looks like linux

slate swan
#

there are like 20 popular distros and idk how many in existence

robust fulcrum
#

@slate swan How to get link of message?

slate swan
unkempt canyonBOT
cloud dawn
robust fulcrum
#

Ty

sick birch
warm lava
#

!e

unkempt canyonBOT
#
Missing required argument

code

#
Command Help

!eval <code, ...>
Can also use: e

*Run Python code and get the results.

This command supports multiple lines of code, including code wrapped inside a formatted code block. Code can be re-evaluated by editing the original message within 10 seconds and clicking the reaction that subsequently appears.

If multiple codeblocks are in a message, all of them will be joined and evaluated, ignoring the text outside of them.

We've done our best to make this sandboxed, but do let us know if you manage to find an issue with it!*

cloud dawn
#

Since when does Discord auto format an url

sweet geyser
cloud dawn
sweet geyser
#

It's a laptop screen so please don't bully me for the huge terminal

slate swan
#

And after I bought sniper
The command response inside the if statement did nothing

supple thorn
slate swan
cloud dawn
slate swan
#

yeh

robust fulcrum
slate swan
#

Lemme try something else in it

supple thorn
cloud dawn
#

!charinfo ”

unkempt canyonBOT
slate swan
slate swan
cloud dawn
sweet geyser
cloud dawn
sweet geyser
#

It doesn't?

sweet geyser
#

Picom for the blur stuff

#

Conky for the timer

supple thorn
#

Hi sarth

slate swan
slate swan
sweet geyser
slate swan
sweet geyser
#

Then use the same usb and flash some other distro

#

Use etcher

slate swan
#

meh im comfy with that for now

sweet geyser
#

Bruh

slate swan
#

its been a year and a half

sweet geyser
#

Kali is the worse distro ever for daily use

#

It will cause you some real problems

slate swan
#

i have pure debian in dual boot so idm

#

i mostly use that

sweet geyser
#

...

vocal plover
slate swan
#

Rule 7 when rooSip

#

lets wait for hunter

#

or sparky

neat field
sweet geyser
#

You don't even use most of the tools

neat field
#

so ?

sweet geyser
#

And considering you use it as a daily driver it can make your overall experience bad

neat field
#

it did not

slate swan
neat field
sweet geyser
slate swan
vocal plover
#

a large or sufficient amount or quantity; more than enough.

neat field
#

yes that means most of the tools

sweet geyser
sweet geyser
#

What does that mean?

vocal plover
#

through proven experience, rather than looking from a purely theoretical or logical perspective

slate swan
#

based on experience/ testing

sweet geyser
#

Some people man they just think Having a GPU and not Having a GPU gives the same performance in games

robust fulcrum
slate swan
vocal plover
#

I don't disagree with the general sentiment, Kali is not a typical daily-drive OS and really isn't designed with that in mind, my point is more that if it works well for someone then let it be; there's little point in convincing someone that a tool they've used doesn't work when for them it evidently does

slate swan
#

Works if I remove if “Sniper” in bag:

neat field
sweet geyser
#

Unless you are a hacker who uses those tools

neat field
#

i can say the same about arch

slate swan
#

If you have good hardware resources available, Kali is fine.

sweet geyser
robust fulcrum
#

conten = (reply.cached_message or await ctx.fetch_message(reply.message_id)) do it return message object?

neat field
slate swan
#

you guys can stop and take this to an ot channel smh

neat field
#

yes daily drive it for about 3 years now

slate swan
robust fulcrum
#

Ty

vocal plover
#

should do

slate swan
#

yes

sweet geyser
#

I never knew there was an or in python :\

neat field
#

I never knew there was an or in python :\

WHAT

slate swan
#

!d discord.ext.commands.Context.fetch_message

unkempt canyonBOT
#

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

Retrieves a single [`Message`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Message "discord.Message") from the destination.
slate swan
#

ok yes that works.

slate swan
unkempt canyonBOT
#

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

this is or
slate swan
#

it looks for the first Trueish value,
and can be used to look for the first Falseish value too

vocal plover
#

truthy and falsy :P

neat field
#

falsey

robust fulcrum
#

And how to add url to title of embed?

neat field
#

Embed(title, url=url)

slate swan
#
@commands.Cog.listener(name="on_member_remove")
        @commands.guild_only()
        async def fm(self,member):
            await member.ban(reason="User left while freeloader mode was on.")

this should ban the user who leaves right?

sweet geyser
#

@neat field I really really mean it arch is not equal to kali, arch is a distro that is made with minimalism in mind and you can install what you want as you go, kali is a distro made for hackers/pentetester it has way too many tools preinstalled which can be useful for an hacker but bloat for a normal user my point is i'm not saying a person to "not use kali as a daily driver" instead i'm saying that it's gonna be seriously worse if you use it as a daily driver when you are not gonna use those tools

neat field
sweet geyser
#

tbh u wiil have more errors on arch than kali
You won't if you know what you are doing

#

It's possible to daily drive kali

#

But still it makes your experience worse i've used it before trust me it ain't fun

neat field
#

what was the issue ?

sweet geyser
#

Way too many login loop errors

sick birch
#

You’re using a specialized OS as a general purpose daily driver, obviously the experience is going to be subpar

neat field
#

ehh

sweet geyser
#

And too many fails in updates

neat field
#

cries in pacman -Syy

sweet geyser
slate swan
#

thats more like a debian/apt thing than kali itself

neat field
#

i did make a script that does that for me so no longer an issue 😄

slate swan
#

also can we move to #ot2-never-nester’s-nightmare or #unix with the discussion cause i feel like people are hesistating with the original topic questions because of an ot discussion

sweet geyser
#

Sorry i'll move there

neat field
#

💯

robust fulcrum
#

How to add url to a value in field of embed?

vale wing
#

Just add it?

neat field
slate swan
#

yes, and you can use the link directly too depending on what you need.

neat field
#

wait u can have url in a field ?

robust fulcrum
#

value=["text"](link here) like this ?

slate swan
vale wing
vale wing
neat field
#

naa i meant as we have in title

lime rampart
#

Hey does bot.latency return how long it took for your bot to finish the command or is it just your ping to discord server?

vale wing
#

!d discord.ext.commands.Bot.latency

unkempt canyonBOT
#

property latency```
Measures latency between a HEARTBEAT and a HEARTBEAT\_ACK in seconds.

This could be referred to as the Discord WebSocket protocol latency.
slate swan
#

^

lime rampart
#

What is heartbeat

slate swan
slate swan
#

No errors

robust fulcrum
slate swan
#

nope, thats optional

robust fulcrum
#

Ok

vale wing
robust fulcrum
slate swan
slate swan
slate swan
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.

robust fulcrum
slate swan
#
import discord
from discord.ext import commands

class fmode(commands.Cog):
    
    def __init__(self, client):
        self.client = client

        @commands.Cog.listener(name="on_member_remove")
        @commands.guild_only()
        async def fm(self,member):
            await member.ban(reason="User left while freeloader mode was on.")
            
async def setup(client):
    await client.add_cog(fmode(client))
vale wing
#

Typehint member

#

And ig you get no errors because of improper error handler, you were supposed to get AttributeError

#

And um 2 decorators?

#

Am I missing something

placid skiff
#

the guld only listener is useless D_D

slate swan
#

@commands.guild_only()
this is useless

placid skiff
#

on_member_remove event will be dispatched when a member leaves a guild

placid skiff
#

yup

slate swan
#

oh demn-

#

Is it not possible to do it for a particular guild

vale wing
#

if exists

placid skiff
#

you have the member object, the member has a guild parameter

#

!d discord.Member.guild

unkempt canyonBOT
placid skiff
#

so you can do something like if member.guild.id == id: #do something

vale wing
#

!e print(id) # 😏

unkempt canyonBOT
#

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

<built-in function id>
placid skiff
#

yeah don't use id as variable name of course D_D

slate swan
#

won't really effect inside a function scope ig

robust fulcrum
#

@slate swan is there any other way to add url to field?

slate swan
#

no

robust fulcrum
#

😩

shrewd apex
#

...

slate swan
#

how do you want it to work

robust fulcrum
#

I want to add messeg jump url to field

shrewd apex
#
embed.add_field(name='\u200b', value="[text](https://google.com)")
robust fulcrum
#

I can't add varible to the link

shrewd apex
#

whats ur variable?

robust fulcrum
#

url

shrewd apex
#

u can in a f string

robust fulcrum
#

I asking will f string wirk

shrewd apex
#

f"[text]({link})"

robust fulcrum
#

Ok

sweet geyser
#
f"{hi}"
slate swan
sweet geyser
#

nvm

sweet geyser
slate swan
#

how to get member avatar url?

#

ema.set_footer(text=f"{member.id}",icon_url=member.avatar.url)
AttributeError: 'str' object has no attribute 'url'

hushed galleon
#

avatar.url only exists in dpy 2.0 / forks, for 1.7.3 you'll have to use avatar_url

robust fulcrum
#

@slate swan

@bot.command()
async def bm(ctx):
    reply = ctx.message.reference
    conten = (reply.cached_message or await ctx.fetch_message(reply.message_id)).content
    contents = (reply.cached_message or await ctx.fetch_message(reply.message_id))
    url = contents.jump_url
    auth = contents.author
    await ctx.send("message bookmarked")
    embf = discord.Embed(title=f"{auth}\nbookmark",color=discord.Color.green())
    embf.add_field(name="bookmark message",value=conten,inline=False)
    embf.add_field(name="bookmark link",value=f"[link to message]({url})", inline=False)
    embf.set_thumbnail(url='https://media.discordapp.net/attachments/993363454519955466/996046786928070696/unknown.png')
    await ctx.author.send(embed=embf)

Done!

shrewd apex
#

nais

robust fulcrum
#

Hmmm

#

Replit XD

sweet geyser
#

nextcord

#

It's a import error

robust fulcrum
#

Me also use replit on mobile

sweet geyser
#

That's just sad man

#

Then why does it say so?

vocal snow
sweet geyser
slate swan
sweet geyser
#

It's dangerous

slate swan
vocal snow
#

its ok there are 10 people every square meter where i live theres no chance anyone will find me

sweet geyser
#

I do and i certainly think the owners don't want anyone being doxed in

sweet geyser
#

How hard do you really think it is to get your name

slate swan
vocal snow
sweet geyser
slate swan
#

how are you uninstalling?

sweet geyser
#

Is the bottom stuff svg?

vocal snow
vocal snow
placid skiff
sweet geyser
#

I would really really like to know how you made that website

vocal snow
slate swan
#

do poetry remove nextcord

#

sad

vocal snow
#

replit uses poetry ?

slate swan
#

replit lemon_raised_eyebrow

slate swan
vocal snow
#

if you come to pune i can give you my old laptop

sweet geyser
#

Why would you use your phone?

slate swan
sweet geyser
#

To code??

#

Ah ok

sweet geyser
vocal snow
vocal snow
#

no lol

slate swan
#

rude

vocal snow
#

think about the downsides, you'll have to meet nova

slate swan
sweet geyser
#

Is nova a pet ?

vocal snow
#

we all live next to each other just check out the fcking population density

vocal snow
#

yes essentially

sweet geyser
#

Actually loll means just moving your feet kinda

#

A single l can change the meaning of everything

slate swan
#

mood killer

slate swan
swift pumice
#

hi guys

#

i have an question

sweet geyser
#

Don't ask to ask

#

Just ask

slate swan
sweet geyser
swift pumice
swift pumice
#

thanks

slate swan
#

same code with remove_roles instead of add_roles

swift pumice
#

thank you :D

sweet geyser
slate swan
#

i mean yeah, dropping the question directly is a quick process

slate swan
#

you can be polite while asking the question itself

sweet geyser
#

They just leave me in a suspense especially when i'm giving support to something i made

slate swan
#

i keep waiting for minutes too lmao.

sweet geyser
#

Ah it's ok

slate swan
#

but yeah its totally fine to ask before asking if you really want to

sweet geyser
#

It is but if they are just gonna ask to ask without asking the question it really drives me mad

paper sluice
#

ok, cool

slate swan
swift pumice
#

bro

slate swan
#

😂 lets not make it a topic to debate about.

swift pumice
#

why are u discussing now about that

sweet geyser
#

I really don't know why whenever i chat i start a debate

slate swan
#

btwww i found a way to attach more than 1 image in Embed's image field

slow fog
swift pumice
slow fog
swift pumice
#

i just like the anime xd

slate swan
#

like this, and yeah all of them are different

slow fog
sweet geyser
#

?av

slate swan
#

🌚

swift pumice
slow fog
sweet geyser
slate swan
#

lemon_smile lemon best.

slate swan
swift pumice
slate swan
#

.topic

lament depotBOT
#
**What feature would you be the most interested in making?**

Suggest more topics here!

robust fulcrum
slate swan
sweet geyser
#

Yeah i k

slow fog
paper sluice
robust fulcrum
#

@slate swan

#

Comamnd done

#

How can I add the reaction thing?

slate swan
#

now use wait_for with "reaction_add_event" and keep waiting for the event to dispatch until people stop reacting (using a timeout)

#

this is basically what it will look like

#
*part of code*   
      await ctx.send(
            embed=embed,
            components = [
                Select(
                    placeholder = "Выберите нужный раздел!",
                    options = [
                        SelectOption(label = "Развлечения", emoji=":balloon:", value = "fun"),
                        SelectOption(label = "Связь", emoji=":e_mail:", value = "conenect"),
                        SelectOption(label = "Приватные войсы", emoji=":mobile_phone:", value = "private"),
                        SelectOption(label = "Свадьбы", emoji=":ring:", value = "marry"),
                        SelectOption(label = "Экономика", emoji=":dollar:", value = "eco"),
                        SelectOption(label = "Профиль", emoji=":man_frowning:", value = "profile"),
                        SelectOption(label = "Реакции", emoji=":grinning:", value = "react"),
                        SelectOption(label = "Модерация", emoji=":shield:", value = "moder")
                    ]
                )
            ]
        )
        res = await self.bot.wait_for("select_option")
        await res.respond(content="тест успешен")

hello everyone, i have a problem. Bot writing error "the interaction failed", i dont know why, help pls(
(this code writing in cogs)
libbary: discord_components
lang: python

sick birch
#

Can you provide the full traceback please? Hard to diagnose the error with nothing more than "interaction error"

slate swan
#

in console dont writing a error

sick birch
#

I'm talking about any errors in your terminal

#

The generic "interaction error" on discord is, well, generic and doesn't help much

slate swan
sick birch
#

Do you have any error handlers?

slate swan
slate swan
slate swan
slate swan
#

is that Interaction Failed or Interaction Not Responded

slate swan
sick birch
#

Could just be an issue with discord_components

slate swan
#

what library are you usin... oh f that ;-;

#

i think its pretty much outdated.

sick birch
#

I feel like it might have to do with those last 2 lines

slate swan
sick birch
slate swan
#

yeah they should be using discord.py v2 for components. that would be the best.

slate swan
sick birch
#

@slate swan I would say be 100% sure you don't have any error handlers. I don't see any other reason for why you wouldn't be getting any errors in console

slate swan
#

is select_menu even an event

#

im sure its not in dpy, but is it in that library?

sick birch
#

I guess discord_components made it one

#

I've seen similar things, like button_click, so I would assume yes

slate swan
paper sluice
sick birch
#

..Which means something went wrong in your code. Yet you don't have any errors in console. Which is what leads me to believe you have a faulty error handler eating up errors somewhere

slate swan
placid skiff
#

Bro read what robin said D_D

slate swan
#

Damn, I don't speak English well, it's hard to explain the problem

paper sluice
#

just use discord.py2.0

slate swan
placid skiff
#

Lmao no you will have to change all slash commands deco's

sick birch
#

If they don't have any interactions, then yes

placid skiff
#

The interaction is his problem

sick birch
#

If they have things like application commands, buttons, select menus, etc, yes you will have to rewerite

slate swan
#

мб по русски базарит кто?

daring olive
#

!rule 4 hi there, please use english

unkempt canyonBOT
#

4. Use English to the best of your ability. Be polite if someone speaks English imperfectly.

slate swan
paper sluice
#

you just have to adjust the your previous code to dpy
you already did the hard parts of figuring out the structure of your previous code, now you just to have to tweak it slightly which is easier than it looks

slate swan
#

is there anyway of making a restart bot command? ive looked on youtube and google found nothing?

slate swan
robust fulcrum
#

Hi

slate swan
slate swan
#

again, just the bot or the complete script?

zinc reef
#

usually, your script pretty much runs the bot only

slate swan
#

in case you still dont understand, you want the bot to go offline and come back online again
or the file stops running, and then starts rerunning

slate swan
slate swan
zinc reef
#

and there's no built in way of making your bot restart

slate swan
# slate swan bot

you can use py await bot.close() to stop it, and await bot.connect() to reconnect it to the socket

#

!d discord.Client.connect

unkempt canyonBOT
#

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

Creates a websocket connection and lets the websocket listen to messages from Discord. This is a loop that runs the entire event system and miscellaneous aspects of the library. Control is not resumed until the WebSocket connection is terminated.
zinc reef
slate swan
#

Cheers 🙂

#

!d discord.Client.close

unkempt canyonBOT
#

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

Closes the connection to Discord.
zinc reef
#

the best way would be to use bot.close() and use a process manager restart the bot again

#

The only good way to restart your bot is to shut it down and have your process manager handle it. You can shutdown your bot by running Bot.close().

Do use:

  • run your bot in a process manager such as:
    • systemd
    • openrc (gentoo, devuan)
    • runit (void linux)
    • supervisord
    • upstart (old ubuntu)
    • docker
  • manually reboot it

Do not use:

  • a bash loop (it can eat your C-c by rapidly spawning python and if your bot fails it won't stop it from constantly failing)
  • subprocess.call (you will eat your memory up by not letting your old processes die)
  • os.exec*
slate swan
#

bot.close stops the bot but the script process is still running, dont see how creating another process is good

placid skiff
#

Bruh the hell are you talkin about lmao?

paper sluice
#

@slate swan do you know what is called before the bot shuts down (lightbulb.BotApp)
I tried to overwrite close but it doesn't seem to get called

placid skiff
#

The bot doesn't run with the code, Client or Bot instance has a run method

#

that makes the connection with discord API

paper sluice
#

thx

slate swan
#

figgerd how to do it and it was a lot easer im a bit dumb lol

@bot.command
@commands.has_role('PRO HACKER')
async def restart(ctx):
    await ctx.send("Restarting bot...")
    restart_bot()
#

😄

slate swan
#

what makes you think that wasnt a troll

cold sonnet
#

the average person in need of help in this channel does not know python

vale wing
#

Ikr

#

Just init it in MyView (also please call your cog Tickets it's naming convention)

#

!pep 8

unkempt canyonBOT
#
**PEP 8 - Style Guide for Python Code**
Status

Active

Created

05-Jul-2001

Type

Process

paper sluice
#

its a convention which just means a common good practice

vale wing
#

Starting with small letter, breaking classes naming convention. Should be CamelCase

paper sluice
#

you dont have to follow it if you don't wish to

#

sure

slate swan
#

!resources

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.

vale wing
#

You better do otherwise your code might become unreadable hell for you and others

#

How did you do that

#

You need to init superclass as well

#

I suggest reading about inheritance and OOP generally in python when you have time

flat solstice
#

Can someone link me to the docs for what discord.app_commands.command accepts as args, mainly I'm looking for if I can have a list of attachments as a arg (dpy 2.0)

vale wing
#

Call super().__init__() to init superclass

vale wing
#

Yes

#

But not in cog

#

Cogs don't need superclass init

cloud dawn
#

. not , and you don't need to call the super class.

vale wing
flat solstice
#

hmm well that's annoying

vale wing
#

Right 🥲

cloud dawn
#

You could pass the bot instance ig I personally have a View coded like this.

class MyView(View):
    def __init__(self, bot: Bot, *, timeout: float = 180.0) -> None:
        super().__init__(timeout=timeout)
        self.bot = bot
vale wing
#

^

#

I recommend reading about OOP pretty much

cloud dawn
#

You get this error since MyView doesn't have a timeout attribute. But the View class does we address the View class using the super call.

vale wing
#

Because it doesn't get overwritten and keeps the __init__ from superclass

cloud dawn
#

True since then it grabs the underlying init from View. But since you overwrite it in MyView you have to call it again.

cloud dawn
vale wing
#

Very pro

cloud dawn
slate swan
tranquil relic
#

i have a question about heroku

cloud dawn
#
from discord.ui import View
from discord.ext.commands import Bot

class MyView(View):
    def __init__(self, bot: Bot, *, timeout: float = 180.0) -> None:
        super().__init__(timeout=timeout)
        self.bot = bot
#

View is the base class of implementing Buttons and/or Select menus.

#

Could you provide the error + code?

#

Where do you load the cogs?

#

Could you show that?

#

!pypi py-cord

unkempt canyonBOT
cloud dawn
#

This can also be ```py
bot.load_extensions(["cogs.tickets", "cogs.close"])

#

You don't really have to.

#

With the callback the interaction is passed, that contains the bot variable.

#
async def callback(self, interaction: Interaction) -> None:
    channel = interaction.guild.get_channel(...)
#

@pastel solar get channel does need to come from either a guild or client/bot object.

#

A wait_for is only accessible by the bot/client object.

slate swan
#

wait_for is a Client ONLY method not a Guild method

cloud dawn
#

You would use interaction.bot.wait_for(...)

swift pumice
cloud dawn
#

But I don't recommend using a wait_for these days. Any reason why you would need the message?

#

Use client instead of bot

#

interaction.client.wait_for(...)

slate swan
slate swan
swift pumice
cloud dawn
#

I recommend using a modal for a ticket system.

slate swan
cloud dawn
#

Modals allow you for user input without needing to wait_for and it intergrades better with an interaction.

swift pumice
slate swan
#

its correct then

swift pumice
#

no wait

#

i didnt change anything

#

@slate swan read my question again

swift pumice
#

Bruh wth

#

accident gif sry

cloud dawn
unkempt canyonBOT
#

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

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

yeah and use raw events

cloud dawn
#

Most people like it raw 🐒

slate swan
# swift pumice Bruh wth

the if statements would be same.. thats literally the same code with adds replaced with removes

swift pumice
#

okay

#

thank you

cloud dawn
#

Okay guys I've got kind of an issue, would you rather, have a interaction menu with buttons and dropdown menu's to customize/add something or use slash command instead with little visualization.

golden tapir
#

how can i have input on my discord bot

cloud dawn
#

!d discord.ui.Modal

unkempt canyonBOT
#

class discord.ui.Modal(*, title=..., timeout=None, custom_id=...)```
Represents a UI modal.

This object must be inherited to create a modal popup window within discord.

New in version 2.0.

Examples...
cloud dawn
slate swan
#

use letters instead

cloud dawn
fresh notch
#
@bot.command()
async def ship(ctx, user1:discord.Member, user2:discord.Member):
    try:
        if user1 == user2:
            await ctx.send("You can't ship yourself with yourself")
        else:
            percent = random.randint(1, 101)
            await ctx.send(f"{user1.mention} and {user2.mention} are {percent}% compatible")
    except Exception:
        await ctx.send("Please provide two valid users")

when I try to ship 2 random things it gives an error in the console but doesnt send anything in chat

hardy yoke
#

and the error is

fresh notch
#

raise MemberNotFound(argument)
discord.ext.commands.errors.MemberNotFound: Member "test" not found.

hardy yoke
#

does the bot have member intents

sick birch
fresh notch
#

nope

fresh notch
hardy yoke
#

that would explain the error

fresh notch
#

yeah but the exception block isnt being triggered

hardy yoke
#

because it's erroring on the argument input, it isn't even reaching that try/except

#

you probably want to make an error handler for that command

fresh notch
#

uh i dont understand

hardy yoke
#
    @ship.error
    async def ship_handler(self, ctx, error):
        """A local Error Handler for our command do_repeat.
        This will only listen for errors in ship.
        The global on_command_error will still be invoked after.
        """

        # Check if our required argument inp is missing.
        if isinstance(error, commands.MemberNotFound):
            await ctx.send("Please provide two valid users")```


^ example of a command error handler that should deal with your issue.
fresh notch
#

oh ok

#

thank you

hardy yoke
#

but the error happens HERE so the try/except doesn't come into play

#

the cmd error handler will deal with it tho

#

👍

fresh notch
#

👍

swift pumice
#

hi guys

#

i have a question

#
async def on_reaction_remove(reaction, user):
    Channel = bot.get_channel(988526792602177636)
    if reaction.message.channel.id != Channel.id:
        return
    if reaction.emoji == "🌈":
        Role = nextcord.utils.get(user.guild.roles, name="Divers")
        await user.remove_roles(Role)
    if reaction.emoji == "♀️":
        Role1 = nextcord.utils.get(user.guild.roles, name="Weiblich")
        await user.remove_roles(Role1)
    if reaction.emoji == "♂":
        Role2 = nextcord.utils.get(user.guild.roles, name="Männlich")
        await user.remove_roles(Role2)
    if reaction.emoji == "😳":
        Role3 = nextcord.utils.get(user.guild.roles, name="18+😳")
        await user.remove_roles(Role3)
    if reaction.emoji == "👨‍🦱":
        Role4 = nextcord.utils.get(user.guild.roles, name="15-17")
        await user.remove_roles(Role4)
    if reaction.emoji == "🧒":
        Role5 = nextcord.utils.get(user.guild.roles, name="13-15")
        await user.remove_roles(Role5)```
why isnt this working? it gives nothing in the console too
vale wing
#

You should correct the size by yourself and typehint user with discord.Member instead of discord.User because ig you have separate pfps for servers and discord.User gives the global one

vale wing
#

And yeah variables naming convention is lower_snake_case

cold sonnet
#

and convert reaction.emoji to str

#

and use elif

vale wing
cold sonnet
#

yeah that's better

#

but in case he wants to be a yandere dev

vale wing
#

I kinda don't understand what pfp you need, the global one or the local one?

swift pumice
vale wing
#

These are

swift pumice
#

why

vale wing
#

These are pretty much the same with a few things varying

swift pumice
#

it works

#

u didnt answer my question

vale wing
#

Read about code refactoring when you have time

swift pumice
#

ok

vale wing
swift pumice
#

thanks

#

i mean

#

like i have 2 bot events

swift pumice
vale wing
#

!d discord.on_raw_reaction_remove try this

unkempt canyonBOT
#

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

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

for what is the payload if i can ask?

vale wing
#

Docs exist

swift pumice
#

okay

vale wing
#

Just click the link there

#

And check the attributes out

swift pumice
#

sry, im gonna look further into it later.

vale wing
#

Sure

#

Ok didn't get you at first

#

Lemme check the docs

#

!d discord.Member

unkempt canyonBOT
#

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

This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User").

x == y Checks if two members are equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User") instances too.

x != y Checks if two members are not equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User") instances too.

hash(x) Returns the member’s hash.

str(x) Returns the member’s name with the discriminator.
vale wing
#

!d discord.Member.avatar should work @slate swan

unkempt canyonBOT
#

property avatar```
Equivalent to [`User.avatar`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User.avatar "discord.User.avatar")
swift pumice
#
@bot.event
async def on_raw_reaction_remove(reaction, user):
    Channel = bot.get_channel(988526792602177636)
    if reaction.message.channel.id != Channel.id:
        return
    if reaction.emoji == "🌈":
        Role = nextcord.utils.get(user.guild.roles, name="Divers")
        await user.remove_roles(Role)
    if reaction.emoji == "♀️":
        Role1 = nextcord.utils.get(user.guild.roles, name="Weiblich")
        await user.remove_roles(Role1)
    if reaction.emoji == "♂":
        Role2 = nextcord.utils.get(user.guild.roles, name="Männlich")
        await user.remove_roles(Role2)
    if reaction.emoji == "😳":
        Role3 = nextcord.utils.get(user.guild.roles, name="18+😳")
        await user.remove_roles(Role3)
    if reaction.emoji == "👨‍🦱":
        Role4 = nextcord.utils.get(user.guild.roles, name="15-17")
        await user.remove_roles(Role4)
    if reaction.emoji == "🧒":
        Role5 = nextcord.utils.get(user.guild.roles, name="13-15")
        await user.remove_roles(Role5)
swift pumice
# swift pumice still doesnt work

File "/home/container/.local/lib/python3.10/site-packages/nextcord/client.py", line 445, in _run_event
await coro(*args, **kwargs)
TypeError: on_raw_reaction_remove() missing 1 required positional argument: 'user'
Ignoring exception in on_raw_reaction_remove
Traceback (most recent call last):
File "/home/container/.local/lib/python3.10/site-packages/nextcord/client.py", line 445, in _run_event
await coro(*args, **kwargs)
TypeError: on_raw_reaction_remove() missing 1 required positional argument: 'user'

cloud dawn
#

raw reactions doesn't take reaction, user it's just a payload

#

!d discord.RawReactionActionEvent

unkempt canyonBOT
#

class discord.RawReactionActionEvent```
Represents the payload for a [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") or [`on_raw_reaction_remove()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_raw_reaction_remove "discord.on_raw_reaction_remove") event.
swift pumice
#
@bot.event
async def on_raw_reaction_remove(payload):
    Channel = bot.get_channel(988526792602177636)
    if payload.message.channel_id != Channel.id:
        return
    if payload.emoji == "🌈":
        Role = nextcord.utils.get(payload.guild.roles, name="Divers")
        await payload.remove_roles(Role)
    if payload.emoji == "♀️":
        Role1 = nextcord.utils.get(payload.guild.roles, name="Weiblich")
        await payload.remove_roles(Role1)
    if payload.emoji == "♂":
        Role2 = nextcord.utils.get(payload.guild.roles, name="Männlich")
        await payload.remove_roles(Role2)
    if payload.emoji == "😳":
        Role3 = nextcord.utils.get(payload.guild.roles, name="18+😳")
        await payload.remove_roles(Role3)
    if payload.emoji == "👨‍🦱":
        Role4 = nextcord.utils.get(payload.guild.roles, name="15-17")
        await payload.remove_roles(Role4)
    if payload.emoji == "🧒":
        Role5 = nextcord.utils.get(payload.guild.roles, name="13-15")
        await payload.remove_roles(Role5)
``` i fixed it, but it still doesnt work. do you maybe have an answer? @cloud dawn
sick birch
swift pumice
sick birch
#

Probably because you're comparing a discord.PartialEmoji object to a str, so it will never be true

#

You can try something like this:

if str(payload.emoji) == '😎':
  ...
#

Also please use a dict, the code is very redundant

swift pumice
#

I dont know how to do that, im sorry. i started python a few weeks ago

sick birch
#

Just map the emoji to the name of the role:

mapping = {
  "🍌": "Banana",
  "🍎": "Apple",
  "🍊": "Orange",
  "🍇": "Grape",
}

role = discord.utils.get(payload.guild, mapping[str(payload.emoji)])
# remove role here
sick birch
#

Is the event getting fired?

#

Also are you sure you're reacting to the message in the channel with ID 988526792602177636?

swift pumice
swift pumice
#

sry for late answer

sick birch
#

Try doing a print statement as the first line in the event to see if it's getting triggered in the first place

swift pumice
#

like print(Channel)?

#

@sick birch

sick birch
#

Sure, just print something

swift pumice
#

Okay

sick birch
#

Doesn't matter what it is, we just need to make sure the event is getting fired

swift pumice
#

okay

swift pumice
sick birch
#

Okay, now can you print(str(payload.emoji))?

swift pumice
#

okay

swift pumice
sick birch
#

Did you react in discord?

swift pumice
#

Yes i did

#

it still just prints the channel name

sick birch
#

Can I see the code real fast?

swift pumice
# sick birch Can I see the code real fast?
async def on_raw_reaction_remove(payload):
    Channel = bot.get_channel(988526792602177636)
    print(Channel)
    if payload.message_id != Channel.id:
        return
    if str(payload.emoji) == "🌈":
        print(str(payload.emoji))
        Role = nextcord.utils.get(payload.guild.roles, name="Divers")
        await payload.remove_roles(Role)
    if str(payload.emoji) == "♀️":
        Role1 = nextcord.utils.get(payload.guild.roles, name="Weiblich")
        await payload.remove_roles(Role1)
    if str(payload.emoji) == "♂":
        Role2 = nextcord.utils.get(payload.guild.roles, name="Männlich")
        await payload.remove_roles(Role2)
    if str(payload.emoji) == "😳":
        Role3 = nextcord.utils.get(payload.guild.roles, name="18+😳")
        await payload.remove_roles(Role3)
    if str(payload.emoji) == "👨‍🦱":
        Role4 = nextcord.utils.get(payload.guild.roles, name="15-17")
        await payload.remove_roles(Role4)
    if str(payload.emoji) == "🧒":
        Role5 = nextcord.utils.get(payload.guild.roles, name="13-15")
        await payload.remove_roles(Role5)
sick birch
#

Ah because you put the print statement inside the if

#

Put it as the first line

swift pumice
#

oh ok

swift pumice
sick birch
#

Could you send a screenshot?

swift pumice
sick birch
#

Hmm okay

#

When you reacted in discord, what emoji did you use?

swift pumice
#

🧒

#

this

sick birch
#

And do you have an if case for that?

swift pumice
#

like its the last if

#

it just shows other on discord

sick birch
#

await payload.remove_roles

swift pumice
#

huh?

sick birch
#

I don't believe discord.RawReactionActionEvent has that method

#

Why are you not getting any errors for that?

swift pumice
#

oh

#

I dont know

sick birch
#

Do you have a badly written error handler?

swift pumice
#

i dont have an error handler, kinda

sick birch
#

You should probably try to find it and fix it up because it would've saved us a lot of time

swift pumice
sick birch
#

You can try to get the member object and call the method on that

swift pumice
#

what

#

how can i do that

sick birch
#

It's not ideal but you can try to get it from user_id

swift pumice
#

could u send me example code? sry for being dumb

sick birch
#

Very error prone but here:

member = bot.get_guild(payload.guild_id).get_member(payload.user_id)
#

Putting the checks in place to make it less error prone is up to you

hidden snow
#

hey i asked this question before but then i fell asleep >-> anyways
Im trying to write a message onto a file what somebody inputs a !setname command i made
it keeps giving me errors that i need message.content but i cant use .content in a function with a @client.command decorator

hidden snow
#

^^ and i replaced the open('file.txt','w')

#

and it just sets the file to a weird thing

sick birch
#

In your case, it thinks the message is the discord.ext.commands.Context instance, rather than a discord.Message as you would expect

sick birch
hidden snow
#

so id use ctx?

#

i think i tried that and it didnt work

sick birch
#

What did you try?

#

You may not have tried it the right way

hidden snow
#

i definitly havent tried it the right way

sick birch
#

Well, look at what the error says

hidden snow
#

right it doesnt have the attribute that means i cant use the .ctx at the end of message correct?

sick birch
#

That's right

hidden snow
#

would i use ctx itself?

sick birch
#

str is just a primitive python type, no reason for it to have a context as that's a discord concept

#

You could just use message

#

So if I were to run this command, given your bot's prefix was !:

!setname "Hello, world!"

the message variable would be Hello, world!

hidden snow
#

oh that works

#

ok but why?

#

i put in an argument but i didnt even use it

sick birch
#

You didn't use it but discord.py always provides the context as the first argument

#

if you removed ctx, then message would be the first argument, which would be the context instead

hidden snow
#

ahhhh

#

is that the case with every function or only functions with the decorator of clientcommand

sick birch
hidden snow
#

where can i learn what that means?

#

does that apply to like client event?

sick birch
#

Only commands will provide you with a commands.Context instance

hidden snow
#

ah alright

#

ty thats very helpful

slate swan
#

hi guys. How is it possible to use bot on 1 discord server and check if member in other server has certain role? (bot is a member of other server)

sick birch
#

Make sure you check for edge cases like get_guild or get_member returning None

slate swan
#

you can shorten it as ```py
role_id in bot.get_guild(other_guild_id).get_member(member_id)._roles

hidden snow
#

Hey sorry to come back with a question so quickly, but why is my for loop not working
ive never seen an issue like this before with a for loop

slate swan
#

does the csv file have some content?

hidden snow
#

yes

#

well it has 1 line a header

slate swan
#

did you insert the correct seperator

#

/newline

hidden snow
#

yeah

hidden snow
#

i have commas

#

and newlines

#

well that problem was that i only had the header ig

#

oh nope i didnt have newlines

#

ty sarth!

slate swan
#

@sick birch why it is error here
if (1111 in [role.id for role in member.get_guild(11111).get_member(11111).roles]):
embed = discord.Embed(color=0x37393d,
description=f"{ctx.author.mention}, true")
await ctx.send(embed=embed)
else:
embed = discord.Embed(color=0x37393d,
description=f"{ctx.author.mention}, false")
await ctx.send(embed=embed)

slate swan
#

!d discord.Guild.fetch_member

unkempt canyonBOT
#

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

Retrieves a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") from a guild ID, and a member ID.

Note

This method is an API call. If you have [`Intents.members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.members "discord.Intents.members") and member cache enabled, consider [`get_member()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.get_member "discord.Guild.get_member") instead.

Changed in version 2.0: `member_id` parameter is now positional-only.
golden tapir
#

How can i get a user input

#

useing my bot

slate swan
#

elaborate wym my user input

golden tapir
#

like u give it a name and it says hi and ur name

#

for example

#

Gesse

#

Hi Gesse

slate swan
#

!d discord.on_message

unkempt canyonBOT
#

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

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

Warning

Your bot’s own messages and private messages are sent through this event. This can lead cases of ‘recursion’ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
slate swan
#

use these event

#

!d discord.Message.content message variable there is Message object and you can use .content property to get the message content

unkempt canyonBOT
golden tapir
#

i dont get how this helps

#

when on message

#

when does it store what the user says

slate swan
#

@slate swan may u help me with ?
if (1111 in [role.id for role in member.get_guild(11111).get_member(11111).roles]):
embed = discord.Embed(color=0x37393d,
description=f"{ctx.author.mention}, true")
await ctx.send(embed=embed)
else:
embed = discord.Embed(color=0x37393d,
description=f"{ctx.author.mention}, false")
await ctx.send(embed=embed)

golden tapir
#

discord has no atribute "on_message"

slate swan
#

its a name space

#

it should be used as the name of a callable

slate swan
# golden tapir when on message

on_message is an event, which gets fired when someone sends a message on discord.
the message is stored as a discord.Message object in the first paramater of the on_message function

sleek gyro
#

can my bot send an image file that is in my pc?
something like:

await interaction.response.send_message(/folder/image.png)
slate swan
#

ofcourse.

#

interaction.response.send_message(file=discord.File("the path"))

sleek gyro
#

thank you !

slate swan
#

@slate swan
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'get_member'

                if (995806453753454603 in [role.id for role in
                                           client.get_guild(982622742136389662).get_member(lst[i]).roles]):
                    ktempcount = ktempcount + 1
                if (985871153555976244 in [role.id for role in
                                           client.get_guild(937811716438380624).get_member(lst[i]).roles]):
                    ktempcount = ktempcount + 1
                if (982622893408157696 in [role.id for role in
                                           client.get_guild(937811716438380624).get_member(lst[i]).roles]):
                    ktempcount = ktempcount + 1
                if (995054761797754940 in [role.id for role in
                                           client.get_guild(937811716438380624).get_member(lst[i]).roles]):
                    ktempcount = ktempcount + 1
#

@slate swan how can i fix that if member is not on server or he douesnt have one of roles

slate swan
slate swan
#

you've messed up with intents then. the server id is not in the cache.

slate swan
#

i fixed server id mistake and have it:
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'roles'

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.

slate swan
#

well i give up @slate swan
client.get_guild(937811716438380624).get_member(int(lst[i])).roles]):
AttributeError: 'NoneType' object has no attribute 'roles'

#

what's list

#

if its a list f strings or a dictionary with string values that would never work,

#
@bot.command()
async def trustlist(ctx, user:discord.User=None):
    if user == None:
        await ctx.reply("**⛔ No id provided**")
    try:
        await ctx.guild.unban(user)
    except discord.NotFound:
        await ctx.reply("**⛔ This user doesn't have ban**")
    else:
        await ctx.reply(f"**✅ User {user.mention} is now whitelisted**")``` why this dont work properly?
slate swan
delicate moat
slate swan
#

dude its working fine, but the the bot replies to me at the wrong moments