#discord-bots

1 messages · Page 515 of 1

warm flame
#

my code is quite clean

#

except the jobs foldr

manic wing
slate swan
#

Why not

manic wing
#

every single function in a new folder x.x

warm flame
slate swan
warm flame
#

this is my progress so far

#

work command simular to dankmemer

#

yes just put the emoji in the string

slate swan
#

Or if each job class really has that much then make the folder a package and each file has an __all__ = ('you_class_name_here',) and then an init.py file where u have from . import *

warm flame
#

dont put :thumbsup

slate swan
warm flame
#

just do Win + ; in ur code

#

without having to find the names of emojis

slate swan
#

Then when u wanna access any of the classes you'd just do jobs.class

warm flame
#

i dont think that works in embeds

slate swan
#

It does, just not in titles or footers

warm flame
#

yea dont do it in footers

#

i was stuck on that for liek 15 mintues

slate swan
warm flame
#

as a guy who used unity before, i dont do that

slate swan
#

¯\_(ツ)_/¯

warm flame
#

i find cogs much more effective

#

and clean

#

than having my main.py have 9999 lines of code

#

the only way to earn money in my bot is to beg, and ive been trying to change it for 2 days

manic wing
#

BRO

manic wing
unkempt hawk
#

I've got a notification bot for Slack that I'm gonna convert to a Discord bot, how can I just send a message to a specific channel without having to use events etc.? In slack_sdk it goes like:

WebClient(token=SLACK_TOKEN).chat_postMessage(channel=f"#{channel}", text=message)

What is the equivalent in discord?

manic wing
#

is your code open source

warm flame
#

the earn commands are in earn.py balance commands are in balance.py and lose commands are in lose.py

#

and im glad i did that in the beginning

manic wing
#

pyscho

#

ocd go brr

warm flame
#

i like short code

manic wing
#

mine is 11 or smthing

#

get fucked

warm flame
#

what does ur bot do tho

manic wing
#

everything

#

180 commands

warm flame
#

mine was 19 😎

manic wing
#

11

#

11 > 19

#

have you subclassed bot

warm flame
#

what is that

warm flame
#

so far

manic wing
#

what

warm flame
#

but that number will go above 50 very soon

manic wing
#

I said did you suclass bot

warm flame
#

what is that mean

hasty iron
#

making a new class that inherits from Bot

warm flame
#

i think yes

manic wing
warm flame
#

no

#

i have cogs

#

thats the only classes i have

slate swan
hasty iron
#

you have cogs and you dont know what subclassing is?

warm flame
hasty iron
warm flame
#

i clearly didnt copy paste it fromt eh internet

hasty iron
slate swan
#

im not looking for trash

#

what about nextcord

hasty iron
#

then use another lib

warm flame
#

i was wondering how to make an event handler like the one on discord.js

hasty iron
warm flame
#

and i found a script that is perfect

hasty iron
warm flame
hasty iron
#

that’s simple

slate swan
pliant gulch
#

Is your bot verified??

hasty iron
#

it wont affect non-verified bots

slate swan
#

the bot wont receive guild messages

#

oh

reef shell
slate swan
hasty iron
#

man did you actually read what they said about that intent

pliant gulch
#

People over reacting at the finest

warm flame
manic wing
#

I cant tell if blanket copied any or vice versa

slate swan
#

only if i didnt want to make a verified bot

warm flame
#

but discord.js has more tutorials and guides

slate swan
#

Ok and?

hasty iron
manic wing
#

pfp

slate swan
kindred epoch
hasty iron
warm flame
hasty iron
warm flame
#

or other intents

hasty iron
#

btw commands isnt a valid reason

slate swan
#

receiving messages after the command

warm flame
#

isnt there a special method for that

slate swan
hasty iron
#

for all verified bots*

kindred epoch
#

now it just seems that your just playing ariound @warm flame

slate swan
#

yep

warm flame
#

last time i had to add intents to my discord.js project

slate swan
#

js user detected

warm flame
hasty iron
#

no

slate swan
#

u said discord.js project

warm flame
slate swan
#

wth

warm flame
#

Dropdowns

hasty iron
#

you do realize 2.0 has buttons and stuff right?

warm flame
#

me?

hasty iron
#

no

slate swan
leaden anvil
slate swan
#

so its a must

hasty iron
warm flame
slate swan
#

lol

slate swan
#

thats just a single intent

slate swan
#

Damn, good thing I don't use d.js pepecringe2

#

read the line below

leaden anvil
leaden anvil
hasty iron
#

you should use it

warm flame
# slate swan yes sir ,

my dumb brain was trying to figure out how to add it for like 2 hours until i read the docs

slate swan
hasty iron
#

it wouldn’t take somebody with knowledge 2 hours to do something that simple

warm flame
slate swan
#

^

leaden anvil
slate swan
hasty iron
warm flame
slate swan
#

Then you might need to reconsider how to learn

warm flame
#

i never repeat mistakes now

leaden anvil
slate swan
#

I always learn the language before and make smaller projects before doing something like a bot

hasty iron
#

literally everyone with a brain does that

#

if you think about it for 2 seconds

pliant gulch
#

That's like fighting the end game boss without playing the tutorial first

warm flame
slate swan
#

actually you can learn things while coding a bot , but must be aware about the basics of the language itself

#

People who don't learn the language before are the ones who come here and complain their code is not working but after looking at it it's the most basic error ever seen

hasty iron
#

"oh ill just make a bot with assembly and learn it in the process, yeah that seems logical"

warm flame
#

i watch a 10 minute yt tutorial

#

but the rest, on my own

hasty iron
slate swan
# warm flame ofc i do that

"who tf learns a language then starts coding? i start coding then leaarn the language" , your words , sir.

warm flame
slate swan
#

mhm

hasty iron
#

those are two different meanings

warm flame
#

english is my 2nd language dont judge me

slate swan
hasty iron
#

english is my third

#

english being bad isn’t an excuse

slate swan
warm flame
#

i studied russian and im used to its grammar so dont be surprised if i make some grammatical errors

hasty iron
#

ok

slate swan
#

Grammar errors have nothing to do with words choice but ok

warm flame
#

studying and mastering are pretty much identical in russian

slate swan
#

thats a vocabulary problem tho

#

^

warm flame
#

bro why are we talking abt my english rn?

slate swan
#

no sir

slate swan
#

^^

slate swan
hasty iron
reef shell
#

oh no cringe

warm flame
#

aight imma be honest here, no questions. I watch a 10 - 15 minute tutorial on a language before writing my first project, but thats as far as i go in terms of watching yt tutorials for the first 3 weeks

slate swan
#

lets stop it here , before it goes off topic.

hasty iron
#

10 minutes of learning a language before starting a project

slate swan
#

That's some big brain move

hasty iron
#

are you some kind of any% speedrunner

warm flame
#

yes

#

figure the rest out by myself

hasty iron
#

sounds like hell to me

#

if you do that will lower level languages, you’ll regret living

warm flame
#

i was trying to figure out how random.shuffle worked for like 20 minutes the other day

hasty iron
#

oh man

slate swan
#

You won't go far using that technique keep doing it and one day you'll realize it would've been worth to learn it a lot more than 15 minutes

hasty iron
#

you definitely should not try something like C or C++

pliant gulch
#

Purposely making yourself illiterate

warm flame
#

bro thats how i learned scratch and i never managed to get that habit off so its just stuck

hasty iron
#

scratch

#

seriously man

warm flame
#

that was 4 years ago

#

aight we getting off topic

reef shell
#

my expression rn is exactly like his pfp

slate swan
#

¯_(ツ)_/¯

warm flame
hasty iron
#

no

#

i meant like using learning techniques that you used for scratch isnt going to help at all

hasty iron
#

a bad habit

warm flame
#

ik

#

i just cant sit reading the documentation for like 2 hours

hasty iron
#

you’ll try a lower level language and you’ll just give up instantly because you only watched a 10 minute vid

warm flame
#

because i like to master one and be pro at it

slate swan
#

and what is that?

reef shell
#

html could be a good choice

#

In that case

warm flame
#

oh boy not html

hasty iron
#

you cant master something just by looking at a 10 minute vid about it

warm flame
#

but i still need improvements with some areas

hasty iron
#

how was it

slate swan
#

if it comes to videos , its not important that all they teach you is correct

haughty plover
#

i am making a ticket system, and have the opening all down, but now i want to be able to close a ticket when the role is removed. here is my code.

@bot.event
async def on_raw_reaction_add(payload):
    if payload.channel_id == 892175931664367616:
        if payload.emoji.name == "🆘":
            guild_id = payload.guild_id
            guild = discord.utils.get(bot.guilds, id=739869820136194079)
            role = discord.utils.get(guild.roles, id=892178985587458049)
            member = discord.utils.get(guild.members, id=payload.user_id)
            if member is not None:
                if role is not None:
                    await member.add_roles(role)


@bot.event
async def on_member_update(before, after):
    after_roles = after.roles
    before_roles = before.roles
    for role in after_roles:
        if role.id == 892178985587458049:
            guild = discord.utils.get(bot.guilds, id=739869820136194079)
            ticket_name = discord.utils.get(guild.channels, name=f"{after.name}—ticket")
            if ticket_name is None:
                channel = await guild.create_text_channel(name=f"{after.name}—ticket", category=bot.get_channel(870126606407041034))
            else:
                pass
warm flame
# hasty iron how was it

joining game jams, testing out my skills, trying to make a multiplayer without knowing a thing abt it was very fun

#

but ofc i did have to watch some yt tutorials after, but not in the start where i just test out some stuff

#

aight imma leave before this gets to personal

haughty plover
#

no, i did try to get it to delete when i removed role but there was no errors, and it didnt work

slate swan
#

well , you code does not seem to have any part which deletes a channel

cinder horizon
#

welp where did i go wrong? coz wen i give "None"...it just continues and gives an error saying thumburl can have only "http: or https:"

pliant gulch
#

Your checking the lowercase of thumburl.content to a string which has an uppercase

manic wing
#

this what he means is do == 'none'

cinder horizon
#

oki

#

aight that worked

#

thenks

polar shell
#

How would I go about installing pip for macOS?

slate swan
#

Fuck I love Python

polar shell
#

Oop. Forgot I was in this channel.

slate nymph
#

well, how do i make a prefix command which will set the default bot prefix to arg provided after prefix

slate swan
#

redefine the client

manic wing
#

do not redefine it whatsoever

slate nymph
#

then what?

manic wing
#

its like

slate nymph
#

thanks

manic wing
#
def get_prefix(ctx, message):
  return ['!']

bot = commands.Bot(command_prefix = get_prefix```
slate nymph
#

tho i dont have any idea what database is

leaden anvil
#

I want to debug a statement py await ctx.channel.send(embed=report,components=Select(placeholder = 'SelectMenu',options = [SelectOption(label="Bugs", value="value1"),SelectOption(label="Commands", value="value2"),SelectOption(label="Suggestions", value="value3"),SelectOption(label = "Other", value = "value4")])[[Button(style=ButtonStyle.red, label="Discard", custom_id="n"), Button(style=ButtonStyle.green, label="Send", custom_id="y")]]) it gives me the error: Exception has occurred: TypeError 'Select' object is not subscriptable

slate nymph
#

is it like mysql?

manic wing
manic wing
hasty iron
#

also get_prefix takes bot as first argument and message as second

#

it takes no ctx

manic wing
#

and then they can elaborate on it

hasty iron
#

ok

manic wing
#

seeing as they want to change prefix

#

and someone said redefine client x.x

leaden anvil
hasty iron
#

your code is so uh

half briar
#

@manic wing hi bro can you help me

hasty iron
#

not well arranged

#

we literally cant see anything

manic wing
#

im joking, say the code

half briar
#

😩

#

Thanks

manic wing
# leaden anvil elaborate

I mean as blanket said, the code is dodgy, but somewhere and somehow you did Select(...)[], hence the error

half briar
#
 sc = FFmpegPCMAudio("audio.mp3")
    voi = vc.play(sc)```
#

Why bot not play

#

Audio

manic wing
#

errors?

half briar
#
mport discord
import asyncio
from gtts import gTTS
from discord import FFmpegPCMAudio
from discord.ext import commands
bot = commands.Bot(command_prefix="+")
@bot.event
async def on_ready():
	print(bot.user)
	
	
@bot.command()
async def tts(ctx,*, text:str):
    global gTTS
    language = "es-us"
    user = ctx.author
    speech = gTTS(text=text,lang=language,slow=False)
    speech.save("audio.mp3")
    channel = user.voice.channel
    print(channel)
    vc = await channel.connect()
    print(vc)
    sc = FFmpegPCMAudio("audio.mp3")
    voi = vc.play(sc)
    voi.start()``` this is full code
manic wing
#

Im not great with voiceclients

leaden anvil
manic wing
hasty iron
#

thats not the same thing

manic wing
#

!d discord.abc.Messageable.send

unkempt canyonBOT
#

await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sends a message to the destination with the content given.

The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.

To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.

To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
half briar
#

@manic wing wait i send error

hasty iron
#

the tts for send is just annoying

manic wing
hasty iron
#

and it doesnt play on vc

half briar
#
General
<discord.voice_client.VoiceClient object at 0xb0299c88>
Ignoring exception in command tts:
Traceback (most recent call last):
  File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "<string>", line 23, in tts
  File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.8/site-packages/discord/player.py", line 225, in __init__
    super().__init__(source, executable=executable, args=args, **subprocess_kwargs)
  File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.8/site-packages/discord/player.py", line 138, in __init__
    self._process = self._spawn_process(args, **kwargs)
  File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.8/site-packages/discord/player.py", line 147, in _spawn_process
    raise ClientException(executable + ' was not found.') from None
discord.errors.ClientException: ffmpeg was not found.

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

Traceback (most recent call last):
  File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ClientException: ffmpeg was not found.```
hasty iron
#

oh install ffmpeg

#

(not via pip)

half briar
#

I installed but

hasty iron
#

you didnt

pliant gulch
#

Add it to path

half briar
#

Not work

#

I install from termux

hasty iron
#

how did you install it

leaden anvil
# manic wing but you did, and the error says you did

it says line 54 which is this piece of code: py await ctx.channel.send(embed=report,components=Select(placeholder = 'SelectMenu',options = [SelectOption(label="Bugs", value="value1"),SelectOption(label="Commands", value="value2"),SelectOption(label="Suggestions", value="value3"),SelectOption(label = "Other", value = "value4")])[[Button(style=ButtonStyle.red, label="Discard", custom_id="n"), Button(style=ButtonStyle.green, label="Send", custom_id="y")]])

hasty iron
#

we cant see anything

half briar
#

@hasty iron ?

hasty iron
#

what

leaden anvil
half briar
#

I installed from termux but not work

manic wing
pliant gulch
manic wing
pliant gulch
#

Man 3rd party components impl are so bad lmao

#

Look how bulky that is

#

Just use v2.0

half briar
#

No one can help me 😫 😩

manic wing
half briar
#

I installed

manic wing
manic wing
#

add it to path

half briar
#

How

hasty iron
#

are you using a phone

half briar
#

Yes

hasty iron
#

guessed so

lilac galleon
#

hi i need help

#

anyone free

manic wing
#

with what

slate nymph
#

which is the best database recommended by most devs for discord bots?

hasty iron
#

postgesql

slate nymph
#

okay and?

lilac galleon
#

or send it here

manic wing
#

bro just ask here

manic wing
hasty iron
manic wing
#

my man

hasty iron
hasty iron
#

it only allows a single operation per time

slate nymph
#

oh..

hasty iron
#

mongodb has an async driver but its shit

slate nymph
#

i have no idea how they work

#

is there a module for each database?

hasty iron
#

that one has asyncpg

#

!pypi asyncpg

unkempt canyonBOT
slate nymph
#

ok but like is it a module?

hasty iron
#

asyncpg is a module

slate nymph
#

ok thanks

#

and that can help me store user data

pliant gulch
#

Do keep in mind you actually need to setup the postgres database

slate nymph
#

i m using replit for that

pliant gulch
#

I doubt replit can setup a postgres database lmao

slate nymph
#

oof

pliant gulch
#

You also need knowledge in SQL in order to make queries to the database

hasty iron
#

then stop using replit

slate nymph
#

what is the ide used by devs?

hasty iron
#

use anything you like

pliant gulch
#

I personally use neovim a lot

slate nymph
#

cant use offline ides like vscode

pliant gulch
#

Your mixing two things up here

hasty iron
pliant gulch
#

IDEs are NOT vps's

hasty iron
pliant gulch
#

Code on IDE -> send to VPS -> VPS hosts the code

slate nymph
#

because i want my bot to run 24 hrs and vscode cant help in that

pliant gulch
#

repl.it is just an IDE on a server as its meant for a website/webserver

hasty iron
#

then get a vps

slate nymph
#

whats vps

hasty iron
#

virtual private server

#

google it

pliant gulch
#

then adding your own stuff

hasty iron
#

i clicked A and now i can type

#

progress

slate nymph
#

i have no idea what you guys are talking about... i m a complete noobie

pliant gulch
hasty iron
#

too complicated, ill just stick to vsc

pliant gulch
#

😔 Just read the docs

#

Do :help inside of nvim

slate nymph
slate phoenix
slate nymph
#

and how do i create a vps

reef shell
#

You buy

slate phoenix
#

You buy one

reef shell
#

Not create

slate nymph
#

oh...

reef shell
manic wing
#

:(

slate phoenix
slate nymph
#

aww thanks

hasty iron
#

but it requires a credit card

slate nymph
#

well, i do have a credit card

slate phoenix
#

Then it won’t charge you till your trials up

slate nymph
#

but imma stick to replit since i m not developing aprofessional bot

slate phoenix
#

iirc GCS has a 3 month trial

slate nymph
#

just wanted to know how python works. making a discord bot can help ya get better at python

hasty iron
#

if thats so, you dont even need hosting

slate nymph
#

exactly

#

there are already like thousands of bots in discord which perform different functions.

valid niche
#

it's exactly the opposite

slate nymph
#

it is indeed

valid niche
#

discord bots have a VERY specific style of writing, and require quite a lot of knowledge to get in to

#

it will literally kick you until you are down and keep kicking you if you don't already have most knowledge

#

it is FAR from a learning project

slate swan
#

^

slate nymph
#

well

slate swan
#

learning projects are smth like making a GUI interface, tic-tac-toe, rock-paper-scissors, story-like game where depending on what u choose u have a different outcome, etc

eager gull
#

Can somebody tell me what's wrong with this

slate swan
#

and only when u have a certain amount of knowledge of python discord bots can finally become a learning project

valid niche
#

also due to the fact that the writing style is so specific it will not learn you anything valuable outside of discord bots really

slate swan
slate swan
#

(member, ctx): should be (member):

slate nymph
#

oh...

undone lodge
eager gull
slate swan
slate nymph
#

so where should i start from?

slate swan
#

!projects

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.

undone lodge
valid niche
slate nymph
#

okay thanks

undone lodge
slate swan
undone lodge
valid niche
slate swan
#

also ctx.author.colour won't work because you don't just magically have a role colour when u join

undone lodge
#

where is the memes channel tho

slate swan
#

and as i said earlier, no ctx in on_member_join events

valid niche
# eager gull so what do I do to fix it

well if you want to send a message to a channel you have to define a channel, which you did by doing message.channel, but message isn't defined. You never told it what message to use

#

your code does as instructed. It doesn't have telekinesis powers and knows exactly what you want it to do by reading your mind

#

so you have to give it VERY exact instructions

eager gull
#

Thanks for the help I think I understand now

dim cedar
#

how can i add someone in a discord server without invite with my bot

dim cedar
lament mesa
#

You can't, they need to accept the invite

dim cedar
#

u can do it with bots right

dim cedar
#

authorization

slate swan
dim cedar
lament mesa
dim cedar
slate swan
#

FileNotFoundError: JSON file wasn't found help

dapper cobalt
#

Let me tell you something. A Discord bot is not a magician. It cannot do something that a Discord user cannot do. E.g. You cannot ban someone without ban members permissions, same with bots. You cannot send messages without permissions, same with bots. You cannot DM a user who has their DMs off or you don't share a server with them, same with bots.

dapper cobalt
dim cedar
#

somthing called mee6 verification bot

dapper cobalt
#

Do you mean the "join a server for you" thing?

dim cedar
hasty iron
#

why though

#

oh you can do that through oauth2 iirc

dim cedar
#

it was one of the authorization permissions

dapper cobalt
#

You mean scopes?

hasty iron
dapper cobalt
hasty iron
#

guilds.join scope

dim cedar
hasty iron
ebon adder
#

no idea why this doesn't work ```py
@bot.event
async def on_user_update(before,after):
print("Start")
print("Before =" + str(before.display_avatar.url))
print("After =" + str(after.display_avatar.url))

if after.id == 247478934684303360 and after.display_avatar.url != before.display_avatar.url and after.display_avatar.url != None:
    print("if")
    mbed = nextcord.Embed(
        title = f"👀 {after.name} Has Changed His Pfp Again 👀",
        description = "",
        color = 0x9900FF
    )
    print("mbed")
    mbed.set_image(url = after.avatar.url)
    mbed.set_footer(text = f"[Old Pfp]({before.avatar.url})")
    print("mbed stff")
    channel = await bot.fetch_channel(853613968534929441)
    print("channel")
    await channel.send(embed=mbed)
slate swan
#

error?

dim cedar
#

with that i can make some one join in my server if he authorizes it right?

ebon adder
#

nope

ebon adder
slate swan
#

you sure the event is being triggered?

stray path
dapper cobalt
#

Not sure if nextcord is same as discord.py but try on_member_update.

slate swan
#

it only gets triggered if a user updates their profile

dapper cobalt
stray path
#

:(

ebon adder
#

and still nothing

dapper cobalt
#

Try on_member_update instead of on_user_update.

slate swan
#

^

dim cedar
#

do i have to code for that?

hasty iron
#

yes? ofc?

dim cedar
hasty iron
#

it says it in the description

somber musk
#

i dont understand what i did wrong( the token is a old token i put to hide my actual bot)

slate swan
#

value = f(*args, **kwargs)
File "main.py", line 30, in get_prefix
prefixes[str(message.guild.id)]
KeyError: '881564058602582047'

def get_prefix(client, message):

    with open("prefixes.json", "r") as f:
        prefixes = json.load(f)

    return prefixes[str(message.guild.id)]
dapper cobalt
#

Key '881564058602582047' is not in the JSON file.

#

And I don't really recommend using JSON as a database.

dapper cobalt
#

Use an actual database, I suggest mongo.

dapper cobalt
somber musk
leaden anvil
#

just wanna say something why am I getting these two errors what did I do wrong ? py @client.group(invoke_without_command=True) async def feedback(ctx, *, text = None): try: text = text.split("|") report=discord.Embed(color=0xfff868) report.add_field(name='Pending Confirmation', value=f"{text[1]} #Tittle \r {text[2]} #Description") await ctx.channel.send(embed=report,components=Select(placeholder="Posting where?", options=[SelectOption(label="Bugs", value="A"), SelectOption(label="Commands", value="B"), SelectOption(label="Suggestion", value="C"), SelectOption(label="Other", value="D")][[Button(style=ButtonStyle.red, label="Discard", custom_id="n"), Button(style=ButtonStyle.green, label="Send", custom_id="y")]]) except: await ctx.reply("Please enter `/feedback format` to check how to format.") finally: print("done")Errors: Expected ")" & try statement must have at least one except or finally clause pls tag to reply

somber musk
somber musk
dapper cobalt
#

Add a ")" after that.

dapper cobalt
ebon adder
#
bot = commands.Bot(command_prefix="T!", help_command=None,intents=nextcord.Intents.default())
dapper cobalt
#

Default intents don't include member intents.

ebon adder
#

what?

dapper cobalt
#

!intents try this but change discord to nextcord.

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 the Members and Presences intents, which are needed for events such as on_member 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.

ebon adder
#

really?

leaden anvil
dapper cobalt
#
intents = nextcord.Intents.default()
intents.members = True

bot = commands.Bot(..., intents=intents)
ebon adder
#

let me try it out

#

pog thanks

#

i thought default intents where good enough lol

dapper cobalt
#

Nope. Presence intents aren't in default either.

rustic venture
#
embed.add_field(name='Banned', value=f'{discord.Guild.fetch_ban()}', inline=False)

TypeError: fetch_ban() missing 2 required positional arguments: 'self' and 'user'
idk what i should write in ()

somber musk
#

i installed pynacl in the shell but it still shows this

rustic venture
vocal plover
#

anyway your issue is that you need to call fetch_ban() on an object, not a type, like discord.Guild

rustic venture
#

so what should i use for a object?

vocal plover
#

A guild like message.guild or ctx.guild

rustic venture
slate swan
#

someone has a discord python bot? s

rustic venture
valid niche
placid skiff
valid niche
slate swan
#

@placid skiffyou do

#

can you send me a bot code?

unkempt canyonBOT
#

Hey @valid niche! I noticed you posted a seemingly valid Discord API token in your message and have removed your message. This means that your token has been compromised. Please change your token immediately at: https://discordapp.com/developers/applications/me

Feel free to re-post it with the token removed. If you believe this was a mistake, please let us know!

slate swan
#

like key

valid niche
#

there i invalidated that token

slate swan
#

s

placid skiff
#

Discord generator bot? Lol

vocal plover
valid niche
vocal magnet
#

We only invalidate webhooks, there's no API endpoint to invalidate bot tokens

vocal plover
#

no

slate swan
#

like a bot when you .generate key and so the bot give you a key

#

dayum

#

what do i do when i see this

valid niche
slate swan
placid skiff
vocal plover
dapper cobalt
slate swan
valid niche
dapper cobalt
slate swan
slate swan
#

i did it twice by accident and it got instantly invalidated and got a dm from discord system bot thingy

valid niche
#

or it might have been the dpy server

slate swan
#

it's in dpy

valid niche
#

not sure

vocal magnet
slate swan
#

alr

patent lark
valid niche
#

so the user should have a system message now

patent lark
#

👍

polar shell
#

Hi all, I’ve implemented my bot onto discord. What would I have to do to edit the code?

valid niche
#

tho it smells like you have absolutely 0 experience with programming in general

polar shell
valid niche
#

and keep in mind a discord bot is an VERY complex project

#

and it's not made for any beginner

patent lark
polar shell
valid niche
leaden anvil
#

I have successfully debugged This codepy @client.group(invoke_without_command=True) async def feedback(ctx, *, text = None): try: text = text.split("|") report=discord.Embed(color=0xfff868) report.add_field(name='Pending Confirmation', value=f"{text[1]} #Tittle \r {text[2]} #Description") await ctx.channel.send(embed=report,components=Select(placeholder="Posting where?", options=[SelectOption(label="Bugs", value="A"), SelectOption(label="Commands", value="B"), SelectOption(label="Suggestion", value="C"), SelectOption(label="Other", value="D")][[Button(style=ButtonStyle.red, label="Discard", custom_id="n"), Button(style=ButtonStyle.green, label="Send", custom_id="y")]]) except: await ctx.reply("Please enter `/feedback format` to check how to format.") finally: print("done")Errors: Expected ")" & try statement must have at least one except or finally clause but now it gives me the following error: Exception has occurred: TypeError 'Select' object is not subscriptable actually its a logical exceptions but through debugging I have found that it dues to these errors. pls reply or tag

polar shell
valid niche
patent lark
valid niche
#

!traceback

unkempt canyonBOT
#

Please provide a full traceback to your exception in order for us to identify your issue.

A full traceback could look like:

Traceback (most recent call last):
    File "tiny", line 3, in
        do_something()
    File "tiny", line 2, in do_something
        a = 6 / 0
ZeroDivisionError: integer division or modulo by zero

The best way to read your traceback is bottom to top.

• Identify the exception raised (e.g. ZeroDivisionError)
• Make note of the line number, and navigate there in your program.
• Try to understand why the error occurred.

To read more about exceptions and errors, please refer to the PyDis Wiki or the official Python tutorial.

polar shell
#

Just something to help retain knowledge.

leaden anvil
valid niche
patent lark
polar shell
#

How long would it take to master the basics roughly?

patent lark
#

learn the basics of python, like syntax, how to read and understand tracebacks. learn basics of OOP (Object Oriented Programming), and asynchronous programming.

valid niche
polar shell
#

Just a general time scale, I know everyone's different.

manic wing
patent lark
#

it depends on how you learn, if you watch youtube tutorials for 4 hours then you'll never get where you need to be. but if you experiment and research, try for yourself, you'll learn.

manic wing
#

but function knowledge is needed

pliant gulch
#

Asynchronous programming is definitely not something you can learn only via discord.py

patent lark
#

^

pliant gulch
#

I can confidently say that

polar shell
#

Ok cool! I'll take your guys's advice to heart.

hollow mortar
#

hello

unkempt canyonBOT
#

Hey @hollow mortar!

Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:

• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)

• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:

https://paste.pythondiscord.com

hollow mortar
#

can any one look at my code idk why its not making the ticket config work

#

any help

slate swan
#

listen decorator takes an argument

hollow mortar
slate swan
#

!d discord.ext.commands.Bot.listen

unkempt canyonBOT
#

@listen(name=None)```
A decorator that registers another function as an external event listener. Basically this allows you to listen to multiple events from different places e.g. such as [`on_ready()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_ready "discord.on_ready")

The functions being listened to must be a [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine "(in Python v3.9)").

Example...
hollow mortar
slate swan
hollow mortar
#

no errors it doesnt give me anything

patent lark
hollow mortar
#

it give me nothing like the code not reading it idk why

slate swan
patent lark
#

with the bot.listen() decorator, you do not have to pass the function name you want to listen to.

#

yeah

hollow mortar
#

anyone know whats my problem ?

slate swan
#

do you have an error handler?

#

also , how do you invoke the command..

patent lark
#

your command isnt returning anything? do you have an on_message event maybe? and are not processing commands.

hollow mortar
#

i do this !configure_ticket 894287528306282537 887131186810454099 in the chat and it should create a ticket for me and setup the system idk why its not making

patent lark
#

yep, thats your issue

hollow mortar
#

what is it ?

slate swan
#

ah yes

patent lark
#

you need to process commands in your on_message

#

await bot.process_commands(message)

hollow mortar
#

this is not my problem

#

my problem in line 65

slate swan
patent lark
#

we know, your command isnt working because your on_message event isnt processing commands

slate swan
#

on_message is blocking the commands

hollow mortar
#

oh got it

patent lark
hollow mortar
#

so what should i do ?

#

oh ok

slate swan
#

do what snow just said

hollow mortar
#

where ?

patent lark
#

top or bottom of the event

slate swan
#

below your on_message evnts

patent lark
#
@bot.event
async def on_message(message):
  await bot.process_commands(message)
  #code ```
hollow mortar
#
@bot.event
async def on_message(message):
    await bot.process_commands(message)
    f = open("badwords.txt", "r")
    liness = f.read()
    down = liness.split("\n")
    if any(words in message.content.lower() for words in down):
        await message.channel.purge(limit=1)
        await message.channel.send(f"{message.author.mention}, You can't say that!!")```
#

like this ?

slate swan
#

mhm sure

hollow mortar
#

yup

patent lark
#

yes

#

now your issue should be solved

hollow mortar
#

yeah it works now

#

yup thanks alot man

patent lark
#

👍

leaden anvil
hollow mortar
#

ayo

hollow mortar
patent lark
#

?

hollow mortar
#
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

PS C:\Users\Mohamed_Zeton\Desktop\JOB 1> & C:/Users/Mohamed_Zeton/AppData/Local/Microsoft/WindowsApps/python3.9.exe "c:/Users/Mohamed_Zeton/Desktop/JOB 1/job.py"
CursedMC is ready.
Ignoring exception in on_raw_reaction_add
Traceback (most recent call last):
  File "C:\Users\Mohamed_Zeton\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "c:\Users\Mohamed_Zeton\Desktop\JOB 1\job.py", line 49, in on_raw_reaction_add
    await ticket_channel.set_permissions(role, read_messages=False, send_messages=False)
  File "C:\Users\Mohamed_Zeton\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\abc.py", line 648, in set_permissions
    raise InvalidArgument('target parameter must be either Member or Role')
discord.errors.InvalidArgument: target parameter must be either Member or Role
Ignoring exception in on_raw_reaction_add
Traceback (most recent call last):
  File "C:\Users\Mohamed_Zeton\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "c:\Users\Mohamed_Zeton\Desktop\JOB 1\job.py", line 49, in on_raw_reaction_add
    await ticket_channel.set_permissions(role, read_messages=False, send_messages=False)
  File "C:\Users\Mohamed_Zeton\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\abc.py", line 648, in set_permissions
    raise InvalidArgument('target parameter must be either Member or Role')
discord.errors.InvalidArgument: target parameter must be either Member or Role```
#

after the config it make a channel and mention the use that you have a ticket open it create the channel but dont mention the user

patent lark
#

the role your try to give the member doesnt exist (i think)

hollow mortar
#

yup i think the same

patent lark
#

actually

#

i didnt read the full traceback and made the wrong assumption

#

yeah it cannot find the role to set permissions for

hollow mortar
#

its working now yup

#
@bot.event
async def on_member_join(member):
    guild = bot.get_guild(891031599708266626  what should i put here ? )
    channel = guild.get_channel(886784755083907082)
    await channel.send(f"Welcome {member.mention} to the CursedMC Discord! 🥳")```
#

i forgot which id i should put there and im trying to remmber it any one can help ?

#

the second one is the channel id

#

the first one the role ? or the category ?

patent lark
#

the server id, but that is also not needed for what you're trying to do

#

in the bot.get_guild you're grabbing a guild, which takes an int.

hollow mortar
#

yup

patent lark
#

which you dont even need to do

hollow mortar
#

yup if im using it in 1 server

#

only so no need for the server id

patent lark
#
@bot.event
async def on_member_join(member):
  channel = bot.get_channel(ID)
  await channel.send(f"Welcome {member.mention}")

this would be just fine if the bot is in one server.

hollow mortar
#

yup thats what im planing to do thanks alot man

patent lark
#

👍

slate swan
#

Hi,

I have a little question, discord.py or piscord ?

patent lark
slate swan
#

Thx

hollow mortar
#
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

PS C:\Users\Mohamed_Zeton\Desktop\JOB 1> & C:/Users/Mohamed_Zeton/AppData/Local/Microsoft/WindowsApps/python3.9.exe "c:/Users/Mohamed_Zeton/Desktop/JOB 1/job.py"
CursedMC is ready.
Ignoring exception in on_raw_reaction_add
Traceback (most recent call last):
  File "C:\Users\Mohamed_Zeton\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "c:\Users\Mohamed_Zeton\Desktop\JOB 1\job.py", line 213, in on_raw_reaction_add
    if role is not None:
UnboundLocalError: local variable 'role' referenced before assignment```
#
########### verify ##########
@bot.listen()
async def on_raw_reaction_add(payload):
    message_id = payload.message_id
    if message_id ==  894295748869488650: ## add id msg of the msg you want ppl to react to to get role 
        guild_id = payload.guild_id
        guild = discord.utils.find(lambda g: g.id ==guild_id, bot.guilds)
        if payload.emoji.name == 'Verified':
            role = discord.utils.get(guild.roles, name='Verified')
        if role is not None:
            member = payload.member
            if member is not None:
                await member.add_roles(role)
                print("done")
            else: 
                print("memeber not found")
        else:
            print("role not found ")
#

any help wht this error im sure 100% the role name same as here and the emoji as well

#

and the role of the bot is the top of the role i want the bot to give

patent lark
#

role is only defined if the if statement returns True

#

you only pass to the if role is not None if the if statement returns False.

#

well

hollow mortar
#

didnt understand it

#

it was working before tho

patent lark
#

i'm not thinking clearly lol, give me a second.

hollow mortar
#

ok waiting for you

#

if i can use the role id its better for me no cap

patent lark
#

thats not the issue

hollow mortar
#

whats the issue if you know it

patent lark
#

the way you defined role.

#

role only has an assignment if your if statement returns True, otherwise it doesnt

hollow mortar
#

idk why it doesnt returns true thats the problem its weird cuz the same emoji same name and the role

patent lark
#

your program doesnt know what role is (according to your error)

hollow mortar
#

it says this line

#
        if role is not None:```
#

it says this line in the console

patent lark
#

right, but what is role in this case?

#

role is not defined as your if statement above did not return true

hollow mortar
#
            role = discord.utils.get(guild.roles, name='Verified')```
dapper cobalt
#

Define role as None before getting it, and if the code got the role, it will overwrite it, otherwise, the role will stay as None.

patent lark
#

^

hollow mortar
#

ok so i make role = None

patent lark
#

i was gonna get to that but i wanted to make you understand why it was happening first

#

do you see why your program is doing this?

hollow mortar
#

yup i understand it now

#
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

PS C:\Users\Mohamed_Zeton\Desktop\JOB 1> & C:/Users/Mohamed_Zeton/AppData/Local/Microsoft/WindowsApps/python3.9.exe "c:/Users/Mohamed_Zeton/Desktop/JOB 1/job.py"
CursedMC is ready.
Ignoring exception in on_raw_reaction_add
Traceback (most recent call last):
  File "C:\Users\Mohamed_Zeton\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "c:\Users\Mohamed_Zeton\Desktop\JOB 1\job.py", line 213, in on_raw_reaction_add
    if role is not None:
UnboundLocalError: local variable 'role' referenced before assignment```
#

this error when role = None

somber musk
valid niche
#

i invalidated the token by uploading it to github

somber musk
valid niche
#

yeah that's because i uploaded it to github

somber musk
#

Oh rly tysm

valid niche
#

because i know that discord will invalidate it then

somber musk
#

Ty ☺️☺️

hollow mortar
#

sorry fort he bother tho 'snow'

patent lark
#
@bot.command()
async def test(ctx, ok):
  if ok == "Hi":
    word = ok <- Word is only defined under this if condition assuming it returns True, as your role var in your case
  else:
    word = "Nothing" <- This means word wouldnt be defined here, to encounter that, we can set role as a local variable to be used throughout the function by setting its default value to None, this means if we checked if the word is None, it would be defined.```@hollow mortar
#

no bother, just trying to make you understand

hollow mortar
#

oh got it so what i should do is defined the role on the top of the command right ?

#

that no need for it to be none or true it will always be true

patent lark
#

mhm, role = None, and the value of role can change throughout the program

somber musk
#

is it illegal to make a music bot for just u and ur friends

patent lark
hollow mortar
somber musk
#

what other methods are there

hollow mortar
#

i think its not against spotify tos

#

or sound cloud maybe check there tos

patent lark
#

pretty much every method goes against some ToS, actually.

somber musk
#

bc my friends server is asking me to make one but i dont know how to

hollow mortar
#

idk we cant answear about thing against tos in the server i guess

somber musk
#

sad

patent lark
somber musk
#

i mean, its just me and my friends its not gonna be publicbut ty for the info

hollow mortar
#

when i did this i got this

#
@bot.listen()
async def on_raw_reaction_add(payload):
    message_id = payload.message_id
    if message_id ==  894295748869488650: ## add id msg of the msg you want ppl to react to to get role 
        guild_id = payload.guild_id
        guild = discord.utils.find(lambda g: g.id ==guild_id, bot.guilds)
        role = discord.utils.get(guild.roles, name='Verified')
        if payload.emoji.name == 'Verified':
            print("hi")
        if role is not None:
            member = payload.member
            if member is not None:
                await member.add_roles(role)
                print("done")
            else: 
                print("memeber not found")
        else:
            print("role not found ")```
#

i got this error

#
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

PS C:\Users\Mohamed_Zeton\Desktop\JOB 1> & C:/Users/Mohamed_Zeton/AppData/Local/Microsoft/WindowsApps/python3.9.exe "c:/Users/Mohamed_Zeton/Desktop/JOB 1/job.py"
CursedMC is ready.
Ignoring exception in on_raw_reaction_add
Traceback (most recent call last):
  File "C:\Users\Mohamed_Zeton\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "c:\Users\Mohamed_Zeton\Desktop\JOB 1\job.py", line 217, in on_raw_reaction_add
    await member.add_roles(role)
  File "C:\Users\Mohamed_Zeton\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\member.py", line 777, in add_roles
    await req(guild_id, user_id, role.id, reason=reason)
  File "C:\Users\Mohamed_Zeton\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\http.py", line 248, in request
    raise Forbidden(r, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions```
patent lark
#

bot is missing permissions to do add roles to a user

#

maybe the role your bot is trying to add is above the bots role

hollow mortar
#

the bot have admin perm i dont think let me check again

placid skiff
boreal osprey
#

none of my command outputs are sending :(

hollow mortar
patent lark
boreal osprey
patent lark
#

let me see your on_message event

patent lark
boreal osprey
#

i'll send you all my code

#

so u can inspect

patent lark
hollow mortar
# patent lark hmm..

its weird problem this command were working before good and idk i just changed the server and it doesnt work

patent lark
#

you should make sure the permissions are correct

hollow mortar
#

i will check them but im sure it have perm cuz when i make the ticket command in the same bot it give perms too ppl

dapper cobalt
placid skiff
#

The on_message event doesn t process the command

#

Process the command or change the @bot.event() into @bot.listen()

boreal osprey
#

hmm

boreal osprey
patent lark
dapper cobalt
#

Try sending a message, in your case, "deez nuts", and see if it replies.

placid skiff
boreal osprey
#

nothing is working

patent lark
dapper cobalt
#

Does the on_message event work?

placid skiff
boreal osprey
#

nothing

#

nothin works

#

:(

dapper cobalt
#

Your bot instance is defined in a weird way.

#
intents = Intents().all()
intents.members = True



from discord.ext.commands.errors import ArgumentParsingError, MissingRequiredArgument
bot = commands.Bot(command_prefix='g.', intents = Intents())
#

First of all, it's Intents.all().

#

Second, since you have Intents.all() you don't need to set intents.members to True.

placid skiff
dapper cobalt
#

Second, why did you call Intents in the commands.Bot()?

patent lark
#

yep

dapper cobalt
#

I'm pretty sure your bot is not running at all.

#

!intents have a look at this.

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 the Members and Presences intents, which are needed for events such as on_member 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.

patent lark
#

intents = intents

boreal osprey
#

k is it actually good now

dapper cobalt
#

Yes.

#

Now try running your bot, and see if it prints "hi i am ready to be used".

boreal osprey
#

i mean it was always doing that when i turned it on, even before fixxing it

#

none of the commands was working which was weird

#

but they work now

dapper cobalt
#

You were calling Intents() which made the variable intents very useless.

unkempt hawk
#

How can I "acknowledge" messages so that they only get processed once when checking the message history for messages that came in while the bot was offline? I.e. doing something like

async for message in channel.history(oldest_first=True):
    ...  # Processing the message for the same as I use for `on_message`
dapper cobalt
#

Could you please elaborate?

unkempt hawk
#

Me?

dapper cobalt
#

Yes.

#

I didn't understand what are you trying to do.

unkempt hawk
#

I put in a message like !help, then run the bot, it should process that message as it came in while the bot was offline

hollow mortar
#
@bot.listen()
async def on_raw_reaction_add(payload):
    message_id = payload.message_id
    if message_id ==  894303238533304390: ## add id msg of the msg you want ppl to react to to get role 
        guild_id = payload.guild_id
        guild = discord.utils.find(lambda g: g.id ==guild_id, bot.guilds)
        if payload.emoji.name == 'AU':
            role = discord.utils.get(guild.roles, name='AU')
        elif payload.emoji.name == 'NA':
            role = discord.utils.get(guild.roles, name='NA')
        else:
            role = discord.utils.get(guild.roles, name=payload.emoji.name)
        if role is not None:
            member = payload.member
            if member is not None:
                await member.add_roles(role)
                print("done")
            else: 
                print("memeber not found")
        else:
            print("role not found ")``` 


i have problem in this code everytime i react with the emoji called NA and i have role called NA in the server it says role not found any help
unkempt hawk
#

But I don't want it to be processed again if I restart the bot

#

I'm looking for how you'd ack in message queues

dapper cobalt
#

You can save the ID of messages that got processed.

hollow mortar
dapper cobalt
#

And then check if the ID of the message is in the database you are saving the IDs in, and if it is, then return.

patent lark
#
role = discord.utils.get(payload.guild.roles, id = ID here)```
hollow mortar
#

it works on the test server

#

but doesnt work on the main server bruh weird

dapper cobalt
#

Error?

patent lark
hollow mortar
#

nope no errors in the test server

#

and the main server doesnt see the role idk why

dapper cobalt
patent lark
#

👍 :)

dapper cobalt
hollow mortar
#

yessir

dapper cobalt
#

!d discord.on_raw_reaction_add I gotta take a look at the docs.

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.
hollow mortar
#

this the roles i have on the main server and you can see the bots role is in the top

dapper cobalt
#

Ah, wait.

#

payload doesn't have a guild attribute.

#

Since you've already got the guild, then use guild.roles instead of payload.guild.roles.

#

Oh, hold on. I looked at snow's message.

#

That's my bad.

patent lark
dapper cobalt
#

You can get the guild in a better way though. Use bot.get_guild(guildID). I'm not very sure if the way you get the guild is good.

hollow mortar
#

i tried to add the bot to that perm and still same problem

#

its sooo confusing cuz i have everything sit on and the bot still have the same problem in the main server but the test server no

#

weird

hollow mortar
patent lark
#

you could pass guild.roles with discord.utils.get

dapper cobalt
patent lark
#

or that

#

either works

hollow mortar
#

same problem role not found werirddddd

dapper cobalt
#

Is the role with the ID given in the main server?

patent lark
#
guild = bot.get_guild(guild_id_here)
role = guild.get_role(role_id_here)``` this should return the role
maiden fable
#

Bots cannot use premium stickers?

patent lark
#

hi hunter!

#

and im not sure.

maiden fable
#

Hi

dapper cobalt
#

When is disnake going to be fully done?

dapper cobalt
hollow mortar
#
@bot.event
async def on_raw_reaction_remove(payload):
    message_id = payload.message_id
    if message_id ==  891791302004465665: ## add id msg of the msg you want ppl to react to to get role 
        guild_id = payload.guild_id
        guild = discord.utils.find(lambda g: g.id ==guild_id, bot.guilds)
        if payload.emoji.name == 'AU':
            role = guild.get_role(894303031619887120)
        elif payload.emoji.name == 'NA':
            role = guild.get_role(894303115187216414)
        else:
            role = discord.utils.get(guild.roles, name=payload.emoji.name)
        if role is not None:
            member = guild.get_member(payload.user_id)
            if member is not None:
                await member.remove_roles(role)
                print("done")
            else: 
                print("memeber not found")
        else:
            print("role not found ")```
maiden fable
maiden fable
maiden fable
dapper cobalt
#

Oh, really?

maiden fable
unkempt canyonBOT
dapper cobalt
#

Great, I'll give it a try very soon.

maiden fable
#

Cool

hollow mortar
#

hahahahahha

dapper cobalt
#

Next bot order I get, I'll try out disnake.

hollow mortar
#

LETSS GOOOO I KNOW THE PROBLEM FROM WHERE

maiden fable
#

GJ

dapper cobalt
hollow mortar
#

hahahahahah

#

the problem is the bot in 2 servers test server and the main

maiden fable
hollow mortar
#

and in that code i dont have guild thing

dapper cobalt
#

Yes, lmao!

hollow mortar
#

so i kicked him from the test and left him in only 1 server and it worked

#

lets goo thanks thanks thanks thanks alot @patent lark and @dapper cobalt thank you guys and sorry for the bother

patent lark
#

haha its alright, no bother! i like helping.

unkempt hawk
dapper cobalt
maiden fable
#

!botvars

#

Sooo yea. Everything will be redefined everytime your bot restarts as long as u don't hardcode it

slate swan
#

No need of that ;-;

maiden fable
#

I like spamming tags

patent lark
#

we know

unkempt hawk
#

I've seen there's an ack() function and I assumed it would be used for this

maiden fable
#

:stare: Do I ask those type of questions which no one knows?

hollow mortar
#

shit anther problem bruhhhh

#
@bot.listen()
async def on_raw_reaction_add(payload):
    message_id = payload.message_id
    if message_id ==  894295748869488650: ## add id msg of the msg you want ppl to react to to get role 
        guild_id = payload.guild_id
        guild = discord.utils.find(lambda g: g.id ==guild_id, bot.guilds)
        if payload.emoji.name == 'Verified':
            role = discord.utils.get(guild.roles, name='Verified')
        if role is not None:
            member = payload.member
            if member is not None:
                await member.add_roles(role)
                print("done")
            else: 
                print("memeber not found")
        else:
            print("role not found ")```
#

this code doesnt work i tough the first problem will make him get fixed

slate swan
#

Memeber

hollow mortar
#

UnboundLocalError: local variable 'role' referenced before assignment

maiden fable
#

Hey blanket, do u know about my question?

dapper cobalt
hasty iron
dapper cobalt
#
role = None
if payload.emoji.name == "Verified":
  role = discord.utils.get(guild.roles, name="Verified")
maiden fable
patent lark
maiden fable
#

Raises a discord.Forbidden error

dapper cobalt
hasty iron
hollow mortar
maiden fable
#

:c

dapper cobalt
hasty iron
#

i stopped coding bots like 4 months ago

patent lark
hollow mortar
maiden fable
#

Sad

hollow mortar
#

i tough it will get fixed wit that error but not

dapper cobalt
patent lark
hasty iron
#

it was worth it tbh

#

started many projects but left them unfinished

dapper cobalt
#

E.g. @thick sigil

hollow mortar
# dapper cobalt Try that: ```py role = None if payload.emoji.name == "Verified": role = discor...

like this

@bot.listen()
async def on_raw_reaction_add(payload):
    message_id = payload.message_id
    if message_id ==  894295748869488650: ## add id msg of the msg you want ppl to react to to get role 
        guild_id = payload.guild_id
        guild = discord.utils.find(lambda g: g.id ==guild_id, bot.guilds)
        role = None
        if payload.emoji.name == "Verified":
            role = discord.utils.get(guild.roles, name="Verified")
        if role is not None:
            member = payload.member
            if member is not None:
                await member.add_roles(role)
                print("done")
            else: 
                print("memeber not found")
        else:
            print("role not found ")```
dapper cobalt
#

Ngl, he helped me go through many obstacles that came in my way while learning Python and discord.py.

dapper cobalt
patent lark
#

yeah, i think im slowly drifting away from discord.py. i use to code bots all the time, but for the past few weeks. i just dont really touch on it anymore. ive been creating games/sites, but i still enjoy being here to help others with questions regarding the library.

hollow mortar
patent lark
#

ctx.author.send()

dapper cobalt
#

!d discord.ext.commands.Context.author

unkempt canyonBOT
hollow mortar
patent lark
hasty iron
#

time to make my own discord api

patent lark
hasty iron
#

with my own web framework

dapper cobalt
#

The time I got back into discord.py is when the person I work on a bot with actually did some effort until he got the bot verified (side-note: I've coded about 80% of that bot and he kept updating it.) then I focused more on that bot, and we are now earning many donations and getting so much love from the community!

hollow mortar
#

when i changed it to this still same problem

#
@bot.listen()
async def on_raw_reaction_add(payload):
    message_id = payload.message_id
    if message_id ==  894295748869488650: ## add id msg of the msg you want ppl to react to to get role 
        guild_id = payload.guild_id
        guild = discord.utils.find(lambda g: g.id ==guild_id, bot.guilds)
        role = None
        if payload.emoji.name == "Verified":
            guild = bot.get_guild(886784007960944680)
            role = guild.get_role(887356513809735772)
        if role is not None:
            member = payload.member
            if member is not None:
                await member.add_roles(role)
                print("done")
            else: 
                print("memeber not found")
        else:
            print("role not found ")```
#

weird i tried using the id

patent lark
dapper cobalt
#

If feel that. I also lost motivation to work on my bot since it wasn't getting much attention, and also after seeing all my friends' bots getting so many reach faster than my bot.

patent lark
#

yeah, i know what you mean.

crystal cliff
#

File "main.py", line 152, in <module>
@Bot.command()
AttributeError: 'Command' object has no attribute 'command'
 {im getting this error, but if i take the error out, it moves to the next command & so on.} help needed, pls.

slate swan
#

it's bot, not Bot

#

how did you define bot?

crystal cliff
#

tried that, same error

slate swan
#

how did you define bot?

crystal cliff
#

Bot = commands.Bot

slate swan
#

and the brackets

final iron
slate swan
#

right?

crystal cliff
#

intents = discord.Intents().all()
Bot = commands.Bot(command_prefix=get_prefix, intents=intents,help_command=None) {it was working, great yesterday}

slate swan
#

I'm not sure about the capital letter

final iron
crystal cliff
slate swan
#

oh wait

final iron
#

Did you import commands?

slate swan
#

other decorators

#

before the command line

dapper cobalt
#

Isn't it discord.Intents.all()?

crystal cliff
#

@Bot.command()
async def GN(ctx):
await ctx.send(f"Good Night, {ctx.message.author.mention} 😪") {if it remove it, move to the next command}

patent lark
#

yes

unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

slate swan
dapper cobalt
#

And also ctx.author.mention, no need to use the message attr.

#

!d discord.ext.commands.Context.author

unkempt canyonBOT
crystal cliff
#

intents = discord.Intents().all()

patent lark
#

no

#

intents = discord.Intents.all()

final iron
#

^

slate swan
#

there's no way Bot turned to a command object

#

without you messing with it

#

do you have a command called Bot?

#

hmmm

final iron
#

Can you send the line above the command decorator?

crystal cliff
slate swan
crystal cliff
patent lark
#

...

slate swan
#

I feel like a genius

#

wtf

#

where did you copy this from

#

well I suggest getting a help channel for that

#

I don't even know what that is

crystal cliff
dapper cobalt
#

@crystal cliff You have a command called "Bot".

#

Which means, you've got a Bot function.

#

Which means, you're overwriting your Bot variable.

#

And why are you using a capital B?

crystal cliff
dapper cobalt
#

Can I see your Bot command?

crystal cliff
#

@Bot.command()
async def GN(ctx):
await ctx.send(f"Good Night, {ctx.message.author.mention} 😪")

#

{when i remove, the error, it moves to the next command} 😦