#discord-bots

1 messages · Page 1043 of 1

west mango
#

i mean just manually

frozen patio
#

It was successful tho

west mango
#

just change the code to what it was before

sick birch
#

Java is probably not the best language for that but it works

frozen patio
rain zephyr
#

Hello, I know this is simple but I'm new to coding.

sick birch
west mango
#

but this is also why its a good idea to set up a development git branch and commit before you make major changes to things that work

rain zephyr
#

Thanks

sick birch
#

This is also a Python server

exotic maple
sick birch
frozen patio
sick birch
west mango
frozen patio
west mango
sick birch
#

Not to mention if you’re planning on going into any sort of software development knowing git is a must for working with coworkers

exotic maple
#

i hope

west mango
#

im just trying to help man ¯_(ツ)_/¯
there are so many good reasons to use git down to seeing the specific changes on each commit, rollback options, branching, forking, and so much more

slate swan
#

I've tried this, but i get the error
TypeError: 'bool' object is not callable

message = await bot.wait_for("message", check = user == discord.Member, timeout=30.0)```
west mango
#

I dont say it to be elitist but it will help you

exotic maple
#

ill check out ur idea as mine is bad

west mango
#

we've all been there

#

nice got discord button to kanban ticket integration working fkn finally

regal pulsar
#

you need to install node

west mango
slate swan
#

!e True()

unkempt canyonBOT
#

@slate swan :x: Your eval job has completed with return code 1.

001 | <string>:1: SyntaxWarning: 'bool' object is not callable; perhaps you missed a comma?
002 | Traceback (most recent call last):
003 |   File "<string>", line 1, in <module>
004 | TypeError: 'bool' object is not callable
slate swan
#

thats what youre trying to do

#

oh

regal pulsar
slate swan
#

how do i make it have a callback

sick birch
#

Check has to be a lambda or a function

slate swan
#

oooh

regal pulsar
#

did you just call true lol

sick birch
slate swan
#

would i need to change "message" to something else seeing as its an ID im waiting for?

regal pulsar
#

like so

regal pulsar
#

oh

#

lmao 💀

slate swan
slate swan
sick birch
slate swan
#

literally what i just said

regal pulsar
#

poggywoggy = swallo.content

regal pulsar
#

no brackets

regal pulsar
last mica
#

It's it compulsory that fetching strings from a website with discord.py bot nd aiohttp requires the link to have json in it?

slate swan
last mica
slate swan
#

expected str got bytes

#

how to i make command like /game and then start ping pong

regal pulsar
last mica
slate swan
#

just some apis format their payload with json

regal pulsar
slate swan
#

bruh why do shitty errors happen like thtat

west mango
#

vast majority do

regal pulsar
slate swan
#

no

regal pulsar
#

yes

regal pulsar
west mango
slate swan
west mango
#

I move data around for a living, the very very vast majority of apis use json for payloads

slate swan
#

@regal pulsar

regal pulsar
#

^

slate swan
#

what point are you trying to prove lmfao

#

its just a way of formatting data bro

slate swan
regal pulsar
last mica
west mango
#

you were just saying thats not true if I was understanding correctly

regal pulsar
#

or tick tack toe with tick tack toe code

west mango
#

if not then nvm

slate swan
west mango
#

I must have misinterpreted

slate swan
#

ctx.respond("Pong")?

regal pulsar
#

yeah

west mango
regal pulsar
#

i think its response tho

slate swan
regal pulsar
#

hmm

#

ctx.channel.send

west mango
regal pulsar
west mango
#

look at "ping": probably inconsistent tabs and spaces

slate swan
#

😩 the quotes

west mango
slate swan
#

its not python quotes

west mango
#

didnt even notice that

full lily
brave forge
#

what kind of mistake?

discord.ext.commands.errors.CommandNotFound: Command "rul" is not found```
slate swan
#

“ != "

west mango
#

yep

full lily
slate swan
#

after ping

full lily
brave forge
regal pulsar
#

hows my indentation :)

west mango
#

o.o

full lily
# brave forge what ?

do you have a command rul? The error is showing that you tried to run that command but it was not found

slate swan
west mango
regal pulsar
#

im on mobile

slate swan
#

ok?

full lily
# slate swan

Yeah as the others said, your quotes are not proper quote characters

regal pulsar
#

replace that with quotes

west mango
#

''

regal pulsar
rain zephyr
#

Bot token not showing, thanks.

west mango
#

I mostly use TS so I dont notice quotes usually

west mango
regal pulsar
#

lol

west mango
#

it only shows once, you need to save it in a secrets managerr

rain zephyr
#

im so smart guys

regal pulsar
#

it’s literally written right there

#

lmao

slate swan
#

you need to reset it because of the upcoming changes iirc

west mango
#

intents?

slate swan
#

everything

#

intents, api update

slate swan
#

and other stuff

west mango
#

Discord's API decisions are mind blowing to me from a business perspective

slate swan
#

is anyone here experienced in webscraping using discord commands? dm me pls have some questions

brave forge
#

what kind of mistake?

PS C:\Users\ToxicPenguin\Desktop\Администрация> ```
#

I'm turning it off

west mango
#

not the russian one, but the other one.

#

its a file reference issue likely due to encoding from that name

regal pulsar
brave forge
west mango
#

no I understand that

west mango
#

ToxicPenguin\Desktop\╨┤╨╝╨╕╨╜╨╕╤Б╤В╤А╨░╤Ж╨╕╤П\

regal pulsar
#

wow

slate swan
#

bruh

west mango
#

this is not russian

ornate beacon
#

anything wrong with this?

regal pulsar
#

if anyone knows they’ll help

ornate beacon
#

anything wrong?

brave forge
west mango
ornate beacon
#

nvm

west mango
#

not helping that guy, what an ass

regal pulsar
west mango
#

its how you see if if its not encoding

slate swan
#

im sure thats not russian

regal pulsar
river rain
#

hi, why does guild.members() return an empty list, even though there are members?

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.

river rain
#

okay cool thank you

west mango
regal pulsar
#

hmm yeah

slate swan
#

how to my bot keep be alive

regal pulsar
#

!hosting

rain zephyr
#

Hiya. I am creating a discord bot to showcase who I am. I am new to developing so I'm currently wondering how it can say text when it joins the discord?
I want the message to be
"I have successfully been turned on." or something. I'll change it later on.

regal pulsar
#
Railway

Railway is an infrastructure platform where you can provision infrastructure, develop with that infrastructure locally, and then deploy to the cloud.

rain zephyr
#

I'm using Node JS

regal pulsar
#

try this

slate swan
#

for hosting?

regal pulsar
regal pulsar
rain zephyr
regal pulsar
#

ask here

west mango
#

I use heroku for hosting, used to just keep a webserver online by pinging it but it was jank, and replit shared IP/rate limiting is trash

slate swan
#

heroku is not a too good option either, but yeah it works.

regal pulsar
#

use railway

west mango
#

its worked for me as a lightweight solution, whys that though?

regal pulsar
#

heroku isnt meant for discord bots

#

thats why they give you a domain and port

slate swan
west mango
#

I dont mind paying for convenience and its cheap, I dont get the "not meant for dc bots" thing though, theres nothing too unique about a discord bot imo as far as cloud compute instances go

slate swan
#

railway.app is free too

regal pulsar
west mango
#

I used to use ec2 and it was also fine, but then I quit amazon and lost my discount

slate swan
west mango
#

yeah I was a data engineer on alexa for 3 years

regal pulsar
#

wow

#

why’d you quit

west mango
#

resource usage for something like a discord bot should never be an issue for any compute service thats worth its salt and properly configured

regal pulsar
#

sounds like an amazing job

west mango
#

enough of my stocks vested and I was burnt out tbh

regal pulsar
#

ah

west mango
#

it was a lot of work

river rain
#

hi, sorry again, why does the method user.remove_roles() throw this error:

File "main.py", line 256, in on_raw_reaction_remove
    await user.remove_roles(role) #give the role to the user
AttributeError: 'User' object has no attribute 'remove_roles'

as I've seen it used in the documentations and stuff?

I've also tried

client.remove_roles(user, role)

but that just throws the error

  File "main.py", line 256, in on_raw_reaction_remove
    await client.remove_roles(user, role) #give the role to the user
AttributeError: 'Bot' object has no attribute 'remove_roles'
regal pulsar
heady sluice
#

that's damn old tutorial code

west mango
exotic maple
#

Anyone know how to give option buttons for an arg in a slash cmd?

river rain
#
@client.event
async def on_raw_reaction_remove(reaction):
  data = await get_server_data("reactionroles") #gets data
  info = data[str(reaction.guild_id)]["reactions"] #gets the reaction roles list

  guild = await client.fetch_guild(reaction.guild_id) #gets guild

  user = guild.get_member(reaction.user_id)
  for group in info: #for all the created reaction roles in the server
    if str(group[0]) == str(reaction.message_id): #if the messages reacted to has a reaction role
      if group[2] == reaction.emoji.name: #if it's the correct emoji
        guild = client.get_guild(int(reaction.guild_id)) #gets the guild
        role = discord.utils.get(guild.roles, id=int(group[1])) #gets the role
        await user.remove_roles(role) #remove the role from the user
regal pulsar
west mango
#

lots going on there

slate swan
#

reaction.user_id

regal pulsar
#

!d discord.Reaction

unkempt canyonBOT
#

class discord.Reaction```
Represents a reaction to a message.

Depending on the way this object was created, some of the attributes can
have a value of `None`...
slate swan
#

reaction here being a payload since its a raw event

regal pulsar
#

hmm

slate swan
#

!d discord.RawReactionActionEvent.user_id

unkempt canyonBOT
slate swan
#

how to make ping pong for discord bot

#

bot.latency

#

like when u type /game bot pop out ping pong UI

west mango
#

you can define the role through discord.utils.get then apply to the action. heres something for messages:


role = discord.utils.get(guild.roles,name="rolename."
await message.author.add_roles(role)
slate swan
#

what do yoy even mean by ping pong

#

like

#

when u type /game

#

it just sends ping pong?

#

no

#

like when u say /game PingPong he will pop out pong UI

#

how do i make it

#

??

exotic maple
#

how to give option buttons for an arg in a slash cmd?

slate swan
#

and when ctx.send("<some message>) bot react on message and when u react he delete that messages

#

what do u wanna to make with it?

#

what with?

#

u want to make canculator right?

#

okay

#

like

#

<screen>
<1><2><3>
<4><5><6>
<7><8><9>
<#><0><*>

#

<> are like buttons

#

send it

#

yeah but there is no error in that line

west mango
sick birch
#

a calculator?

#

It's relatively easy if you know how using stacks, queues, and prefix notation

#

hardest part is going from infix to prefix notation

heady sluice
#

bro I didn't understand a single word

sick birch
#

We did a simple calculator that way in Java for a course

west mango
#

its been a pain tbh, thats why im building so many automations lately

#

if youre interested in decentralized collateralized lending protocols maybe lol

slate swan
#
async def add(ctx,a:int,b:int): 
    await ctx.send(f"{a} + {b} = {a+b}") #Adds A and B

@client.command() 
async def sub(ctx,a:int,b:int): 
    await ctx.send(f"{a} - {b} = {a-b}") #Subtracts A and B

@client.command() 
async def multiply(ctx,a:int,b:int): 
    await ctx.send(f"{a} * {b} = {a*b}") #Multplies A and B

@client.command() 
async def divide(ctx,a:int,b:int): 
    await ctx.send(f"{a} / {b} = {a/b}") #Divides A and B
slate swan
#

smth like this?

slate swan
sick birch
#

I don't believe discord has that?

slate swan
#

uh

#

like u got button to play ping pong

#

or tic toe

sick birch
#

Oh with buttons

slate swan
#

yeah

sick birch
#

The discord.py github page has an example tic tac toe with buttons

#

Don't know how well pong would work with buttons however

slate swan
#

or tic toe

sick birch
#

Tic tac toe is relatively easy

slate swan
#

just smth of that

slate swan
sick birch
slate swan
#

thx

sick birch
#

I'd suggest you actually try to understand it though

#

just copy pasting it isn't going to be all that helpful

slate swan
#

uh

#

i see the code

#

that can't help me

#

but thanks for trying to help me

#

do u know when bot send message bot add reaction and when ctx.author react on that reaction message delete

sick birch
#

That's what you wanted isn't it?

sick birch
slate swan
#

yeah but reaction

#

how to bot add on that message

sick birch
#

add_reaction

#

!d discord.Message.add_reaction

unkempt canyonBOT
#

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

Adds a reaction to the message.

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

k

#

emoji=✖️ ?

#

no ,

sick birch
#

It tells you the type

#

It can be one of discord.Emoji, discord.Reaction, discord.PartialEmoji, and just a plain ol' str

slate swan
#

yeah but

#

how when u react with it to message get deleted

sick birch
#

wait_for

#

!d discord.Client.wait_for

unkempt canyonBOT
#

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

Waits for a WebSocket event to be dispatched.

This could be used to wait for a user to reply to a message,
or to react to a message, or to edit a message in a self-contained
way...
slate swan
#

uh uh

sick birch
#

They also have an example:

@client.event
async def on_message(message):
    if message.content.startswith('$thumb'):
        channel = message.channel
        await channel.send('Send me that 👍 reaction, mate')

        def check(reaction, user):
            return user == message.author and str(reaction.emoji) == '👍'

        try:
            reaction, user = await client.wait_for('reaction_add', timeout=60.0, check=check)
        except asyncio.TimeoutError:
            await channel.send('👎')
        else:
            await channel.send('👍')
slate swan
#

would this work?

sick birch
#

That's a question for the interpreter, not us

slate swan
#

im using discord.py 2.0a and i have for example ctx.author.avatar.url
but this is the error:

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'url'
#

same for banner.url

#

the user has no avatar/banner

#

probably use display_avatar instead

ashen prairie
#

Hey, is there any good overall tutorial for a discord bot you all could recommend to me? im trying to understand from the Developer Portal, but it doesnt help me at all

sick birch
slate swan
heady sluice
sick birch
#

Looks we do do have an interpreter in chat

heady sluice
#

interpreter hates db.txt

ashen prairie
heady sluice
#

doesn't open open a file but not close it without a with or a close

slate swan
#

@heady sluice

#

how would i give someone a specific role

frozen patio
#

How do you want to give the role

slate swan
#

from the bot, after

frozen patio
#

Events, commands

slate swan
#

after its done checking if the key is correct

#

Can anyone help? Why does this keep showing error

slate swan
frozen patio
#

so you could put the key in as a variable and see if it matches

#

if not, then don't give the role

slate swan
#

yeah ik

#

but do you have the command to give the role?

heady sluice
#

yeah member.add_roles

#

it's not a command, it's a method

slate swan
#

member.add_roles(id)?

heady sluice
#

role object

frozen patio
#

Like

slate swan
#

ight.

frozen patio
#
else:
   await member.add_roles()
#

I would do if and else statements for your key

slate swan
sick birch
#

Python is telling you that it was expecting something after that line, but it didn't find anything

slate swan
sick birch
#

Hence the "unexpected end of file"

frozen patio
slate swan
#

anyways

#

for the 'member'

regal pulsar
#

hmm

#

its 3am ;/

frozen patio
#

XD

frozen patio
regal pulsar
frozen patio
#
key = [11234242]
@bot.command()
async def CheckKey(ctx, Key):
    member = ctx.member.id
    if (!key):
        await ctx.send("Incorrect key!")
    else:
        await member.add_roles(67545674637745)

@slate swan

#

I think something like this

#

🤔

frozen patio
#

I think IDK

#

I will run it and see

slate swan
#

not working, no error too

regal pulsar
regal pulsar
#

i awaited it

slate swan
#

oh sec i didn't save it LMAO

#

sorry

regal pulsar
#

lol

#

also you need a role object

slate swan
#

you mean role ID right

regal pulsar
#

!d discord.Role

unkempt canyonBOT
#

class discord.Role```
Represents a Discord role in a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild")...
regal pulsar
#

so

#
key_given = [11234242]
@bot.command()
async def check(ctx, key: int):
    if key != key_given:
        await ctx.channel.send("Incorrect key!")
    else:
        role = await ctx.guild.get_role(67545674637745)
        await ctx.author.add_roles(role)

@slate swan

slate swan
#

ctx.guild.get_role(67545674637745)

inside the parenthesis you put the role ID right?

slate swan
#

Okay

frozen patio
#

Well I ran it

#

and the key will always be wrong no matter what

slate swan
#

doesn't work for me

#

this is what i did

torn sail
regal pulsar
#

oh yeah a list

#

mb

#
key_given = [11234242]
@bot.command()
async def check(ctx, key: int):
    if key in key_given:
        await ctx.channel.send("Incorrect key!")
    else:
        role = ctx.guild.get_role(67545674637745)
        await ctx.author.add_roles(role)

@slate swan

slate swan
torn sail
#

ctx.guild.get_role is a sync function

regal pulsar
#

keep getting mixed up with fetch_role

torn sail
regal pulsar
#

lmao

slate swan
#

i seen 2-3 people do that now im used to it

torn sail
#

It’s useless so should remove

slate swan
heady sluice
#

role = ctx.guild.get_role(67545674637745)

#

but your id is 14 digits

#

should be 18

#

sus

fringe harness
#

I am trying to create a discord bot that returns stock info, if anyone can help me, send me a dm

#

I am trying to create commands like “!stock MSFT” but I dont want to create commands for every stock so should I create a stock class with the properties self and ticker?

#

@slate swan

exotic maple
#

Code

Error

How to fix?

humble fern
#

@commands.slash_command(description="Wysyła sociale", guilds=test_guilds)

#

i think, i dont remember with disnake

urban oasis
#

how do i code a bot or webhook that takes a picture of this and sends it in a channel?

wicked atlas
#

Global slash commands take some time to update. They might show up at some point in the next few hours. If you want them to show up and update instantly, you can specify a list of guild ids to the guild_ids parameter of slash_command, and it will add the command to only those guilds.

strong vector
west mango
#

lol it blows my mind how many public repos I just saw using sql libraries and passing raw unsanitized strings

#

well only 2 to be exact but it was only in the course of 10 mins

strong vector
#
intents = discord.Intents.all()

webhooks = Tree("webhooks")

client = discord.Client(intents=intents)

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


bot.run("token")

whats wrong with my code?

discord.errors.HTTPException: 401 Unauthorized (error code: 0): 401: Unauthorized
RuntimeError: Event loop is closed
west mango
#

authentication issue for HTTP endpoint youre trying to connect to

#

you arent using approved credentials to connect

strong vector
#

maybe the problem with my token

west mango
#

probably

strong vector
#

i used my old bot code and its working fine. why i am getting this

#

i made a new bot app and still get the same error

west mango
#

were you also using webhooks to connect before?

#

are you passing it as an environment variable?

strong vector
west mango
#

no its your auth, it looks like youre mixing up webhooks and normal authentication

strong vector
west mango
#

good idea, if you do that and run into more issues try printing your token to console to verify that youre not passing anything youre not meaning to. Sorry I actually had to leave right after the first comment I made so I cant help much

strong vector
#
import discord
from discord.ext import commands
intents = discord.Intents.all()

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

@bot.event
async def  on_ready():
    print("Ready !")



bot.run("token")

i getting the same error? why this is happing to me...

#

i stealed the code lol

strong vector
#

i think it's the settings

empty kernel
#

2 Questions

  1. I setup a private server/guild for testing. I'm the only user (plus a bot I'm working on). Is there an easy way to test the on_member_join() event?
  2. I was looking at the discord bot tutorial on RealPython (https://realpython.com/how-to-make-a-discord-bot-python/) and noticed they use:
client = discord.Client()

But many other tutorials and much of the code I see here uses:

from discord.ext import commands
client = commands.Bot(...)

Just wonder if anyone can speak to the differences? Pros/Cons? Etc.

In this step-by-step tutorial, you'll learn how to make a Discord bot in Python and interact with several APIs. You'll learn how to handle events, accept commands, validate and verify input, and all the basics that can help you create useful and exciting automations!

strong vector
empty kernel
#

"v" as in version? No. Maybe RealPython is using an older version?

strong vector
empty kernel
#

gotcha. Thanks!! I'll look more closely at that, but you're probably right. Much appreciated 👍

slate swan
#
class BookMark(commands.Cog):

    data = Data()

    def __init__(self, bot):
        self.bot = bot

    @commands.Cog.listener()
    async def on_ready(self):
        pass

    @commands.command()
    async def bm(self, ctx: disnake.CommandInteraction, name):
        await ctx.send(name)
    
def setup(bot):
    bot.add_cog(BookMark(bot))

this text command doesnt work at all, nothing happens when i run ..bm test

torn sail
#

Also if u use commands.Bot name it bot not client

empty kernel
#

Is there an easy way to test the on_member_join() event? I have a test server, I'm already member (since I'm the owner) and I don't want to bug a friend to join/leave over and over again while I test

torn sail
#

maybe make an alt

empty kernel
#

I can do that, I just wasn't sure if there was some "built-in" way that discord has (specifically for testing)

wary crystal
#

You still are requred at least a Member obect though

torn sail
wary crystal
empty kernel
#

Maybe making an alt account is the easiest 🙂 no need to overcomplicate things. Oh! I'll try that out though!

wary crystal
#

You just need to make sure you have an actual discord.Member object to dispatch

#

Everything after should be fine

empty kernel
#

Gotcha. Thanks! @wary crystal

slate swan
#

ive actually never seen it😅

boreal ravine
#

Yes

boreal ravine
slate swan
slate swan
boreal ravine
slate swan
#

thx

young acorn
#

So i keep running into a situation where the bot.channel(id) is erroring out. Is it possible to do a try/except on async functions?

slate swan
#

error means its returning None right?

silver wolf
young acorn
#

Said "Gateway timed out"

honest laurel
young acorn
#

This is the snippet. The fetch channel times out and kills the loop from functioning in the future until I reset the server

#

(Was saying bot.channel(), I actually was using fetch_channel)

wary crystal
#

The best thing to do would be to wait for discord to fix their server(s)

slate swan
#

that may also happen because of slow internet from your side.

silver wolf
#

assuming ur using 2.0 because there was a change

slate swan
#

👀

#

because the user/id endpoint ks working wel for me.

wary crystal
#

But, I wouldn't rule out the possibility, yea.

#

I'm just going off discords' documentation, stating 5xx error codes is server sided

slate swan
#

is it possible to run a command which is having 3 args but the user sent 2?

#

make one of them have a default value

native wedge
#

i wanna make a slash command with disnake
and i want it to be
/verify username:

how do i take what the author says for username to turn it into a variable

wary crystal
young acorn
#

Its an intermittent time out, usually a couple of days. Used to have no problems at all, seems to happen more often lately.

zealous jay
#

How can I get a channel by it's id and send a message on it with discord.py 2.0?

#
channel = client.get_channel(channel_id)
await channel.send_message("message")
#

I used to do this but it doesn't work on the new version

slate swan
zealous jay
#

oh my bad, I used to have channel.send("message") but changed it while testing

#

Just in case, this is the error:
AttributeError: 'NoneType' object has no attribute 'send'

slate swan
#

then

#
channel = client.get_channel(id) or await client.fetch_channel(id)
#

@zealous jay

zealous jay
#

I'll try that

#

I only use one of them, right?

#

it worked

#

with fetch, thanks

slate swan
#

:D

young acorn
zealous jay
#

How can I edit this embed?

#

.edit doesn't work

slate swan
#

no

zealous jay
#

btw the code is probably horrible but im just testing

slate swan
#

the msg u want to edit make it a var

#

when u send

#

then msg.edit

zealous jay
#

and what value do I give to that var

heavy shard
#

is cog_unload() of Rapptz's module called when bot gracefully exits? (for example on Ctrl+C)

slate swan
#

like

send = await channel.send("hi")
await send.edit()
zealous jay
#

oh that works

#

thanks

slate swan
#

np

slate swan
slate swan
# zealous jay

asyncio.sleep is also a coro, i.e. you have to await it

zealous jay
#

oops

#

yeah I missed that

slate swan
#

why should we avoid time.sleep ?

slate swan
# zealous jay oops

and you dont have to use seperate sends for mentioning
you can just

await channel.send("@compact totem", embed=embed)```
zealous jay
#

oh

stone beacon
zealous jay
#

in my defense it's old code and im just testing things hehe

slate swan
zealous jay
#

where

slate swan
# zealous jay where

you're creating the same embed again
if you wanna change any of the fields, you can just reset them


embed = discord.Embed(title="sparky uwu")
await ctx.send(embed=embed)
await asyncio.sleep(0.88888777777769)
embed.title = "sparky not uwu"
await ctx.send(embed=embed)```
ease
zealous jay
#

oh true

humble fern
#
class events(commands.Cog):
        def __init__(self, bot):
            self.bot = bot
    
        @commands.Cog.listener()
        async def on_guild_join(self, guild):
            auth = await self.bot.db.fetch('SELECT authorized FROM guilds WHERE "guild_id" = $1', guild.id)
            if auth == True:
                print("Authorized")
                pass
            else:
                print(f"Not authorized, leaving {guild.name}")
                await guild.leave()
            ```

```py

        @commands.command(hidden=True)
        @commands.is_owner()
        async def authorize(self, ctx, *, ID: int):
            await self.bot.db.execute('UPDATE guilds SET authorized = $1 WHERE "guild_id" = $2', True, ID)
            await ctx.send(f"Authorized {ID}")```

I'm trying to make a authorization-based bot, and have a Postgres Database to store a Guild ID, Prefix, and if the guild ID is authorized (using boolean) and I am having trouble actually doing it

My commands here, authorize is supposed to set the authorization to True and then set it with the guild ID, which authorization works (I think, I don't know how to check if it actually updates it), but when I make the bot join a authorized server, it still leaves, same if it wasn't authorized, I don't know what to do.
zealous jay
#

thanks again Ashley

slate swan
#

!d discord.ext.commands.Context

unkempt canyonBOT
#
class discord.ext.commands.Context(*, message, bot, view, args=..., kwargs=..., prefix=None, command=None, invoked_with=None, invoked_parents=..., invoked_subcommand=None, ...)```
Represents the context in which a command is being invoked under.

This class contains a lot of meta data to help you understand more about
the invocation context. This class is not created manually and is instead
passed around to commands as the first parameter.

This class implements the [`Messageable`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable "discord.abc.Messageable") ABC.
slate swan
#

huh

supple thorn
#

!d discord.ext.commands.Context

unkempt canyonBOT
#
class discord.ext.commands.Context(*, message, bot, view, args=..., kwargs=..., prefix=None, command=None, invoked_with=None, invoked_parents=..., invoked_subcommand=None, ...)```
Represents the context in which a command is being invoked under.

This class contains a lot of meta data to help you understand more about
the invocation context. This class is not created manually and is instead
passed around to commands as the first parameter.

This class implements the [`Messageable`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable "discord.abc.Messageable") ABC.
slate swan
#

late

slate swan
humble fern
slate swan
zealous jay
#

oh and is it possible to edit a field like the ones added with add_field?

slate swan
slate swan
#

!d discord.Embed.fields

unkempt canyonBOT
#

property fields```
Returns a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of `EmbedProxy` denoting the field contents.

See [`add_field()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.add_field "discord.Embed.add_field") for possible values you can access.

If the attribute has no value then `None` is returned.
humble fern
#

im stupid lol

slate swan
humble fern
#

IS THERE A WAY TO GET RID OF THIS BRO

slate swan
#

ctrl + a

#

backspace

humble fern
#

wdym by that lol

slate swan
humble fern
#

it happens when i start my bot and i have to ctrl c

slate swan
#

type quit

humble fern
#

i just ctrl c but its annoying

slate swan
#

type quit

#

and see what happens

humble fern
#

it does the same thing

slate swan
#

um

#

idk

slate swan
# humble fern yeah

just on a side note, its a good practice to:

example = True
if example:
     print("print, example is set to True")
if not example:
      print("example is se to False")

''' Its recommended not to use arithmetical ops like `==` to compare bools '''

''' or as an alternative (use the above method than this, preferred) '''

if example is True:
      print("example is set to True")
if example is False:
      print("example is set to False")
#

sparky, thats an example

humble fern
slate swan
#

ye ik jk

slate swan
humble fern
slate swan
slate swan
#

its 8:55 am, here.

slate swan
humble fern
slate swan
slate swan
slate swan
#

!e
print(8-4)

humble fern
#

ok i have a question ashley can i get a server name from {id.name}

unkempt canyonBOT
#

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

4
slate swan
#

💀 sleep

humble fern
#

i will trry and see

humble fern
#

wait i can use guild.fetch_guild or whatever without my bot being the server right @slate swan

humble fern
#

i thought i could

humble fern
#

guild id

slate swan
#

id or guild object?

#

did u get/fetch that?

humble fern
#

no

slate swan
#

huh

humble fern
#

it's a kwarg

#

async def authorize(self, ctx, *, ID: int):

slate swan
humble fern
#

or will it still return none

slate swan
humble fern
slate swan
#

which id u want

humble fern
#

because i'm using ID to put it into my database

slate swan
#

.

#

!d discord.ext.commands.Bot.fetch_guild

unkempt canyonBOT
#

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

Retrieves a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild") from an ID...
humble fern
#

guild_id @slate swan

slate swan
#

!d discord.ext.commands.Bot.get_guild

unkempt canyonBOT
slate swan
#

get_guild looks in the cache of the app for the Guild object and fetch_guild makes an api call to get a Guild object
I recommend making a getch

#

@slate swan have u tried party mode

humble fern
#

a getch

slate swan
slate swan
slate swan
supple thorn
#

How many getches does disnake have

slate swan
#

fast its very cool

slate swan
#

uh about phone idk

slate swan
#

ssssssssssssssssssssssssssssssss

#

its cool

slate swan
slate swan
#

its on pc

#

try on pc its cool

supple thorn
slate swan
slate swan
#

you have to make your own getches

humble fern
#

does @unkempt canyon have pypi

slate swan
unkempt canyonBOT
#
Missing required argument

package

#
Command Help

!pypi <package>
Can also use: pack, package, pip

Provide information about a specific package from PyPI.

humble fern
#

!pypi discord-ext-getch

unkempt canyonBOT
supple thorn
unkempt canyonBOT
supple thorn
#

Yes

slate swan
#

the usage example, eww

humble fern
#

I KNOW

slate swan
paper sluice
humble fern
#
        async def on_guild_join(self, guild):
            for guild in self.guilds:```
#

is this right to loop thru all guilds

supple thorn
humble fern
#

yes

frozen patio
#

👀

supple thorn
#

That is not right

humble fern
#

fuck i am so bad

frozen patio
#

um Ok Sparky

supple thorn
#

I'm too lazy to help since ashley and ryuga here

#

So i'm out

slate swan
#

Lol

#

okay thats illegal now?

frozen patio
#

Apparently

slate swan
#

!pip Sparky

unkempt canyonBOT
frozen patio
slate swan
#

RIP

frozen patio
#

Rip bozo

supple thorn
#

Rip

slate swan
#

totally fucked up

frozen patio
#

Meh

#

Ima just make an API using FastAPI

supple thorn
#

ok

frozen patio
#

Ok

slate swan
#

ok

frozen patio
#

OK

slate swan
#

OK

slate swan
#

LOL

frozen patio
slate swan
slate swan
frozen patio
#

I made a neural network on JS

slate swan
#

whats that

frozen patio
#

I was bored ngl

slate swan
supple thorn
frozen patio
slate swan
supple thorn
#

Where mods

slate swan
humble fern
#

oh my god

neat shuttle
#

ashley why does Everybody, indeed, hates you?

humble fern
neat shuttle
#

😭

slate swan
#

..

supple thorn
slate swan
supple thorn
#

Where is it

frozen patio
# slate swan 😐 💀

But it makes something automated by communicating with censors on the screen, and then neural network determines what to do then send it back to the screen to go through it

slate swan
neat shuttle
frozen patio
slate swan
#

Dark light

neat shuttle
#

@slate swan wsp?

slate swan
frozen patio
neat shuttle
#

lmao jit tripping

slate swan
slate swan
frozen patio
slate swan
#

imma go and create a dashboard :) for my bot

#

its not even in 2 servers

#

I think ill rewrite this one to un-shit this 😔

#

with no js

stone beacon
#

Gl m8

supple thorn
#

Aight i'll check it out later when i remember

slate swan
#

short forms

slate swan
#

ill just rewrite that lib

#

rly logs?

#

at least no one will use it for a database 😔

frozen patio
slate swan
slate swan
frozen patio
slate swan
#

neural network sounds like a brain network

humble fern
#

ashley dms

frozen patio
#

Hard to code

slate swan
#

its like ai?

frozen patio
#

Yes but very advanced

paper sluice
frozen patio
#

In JS with no libs

frozen patio
slate swan
#

hello world on html

#

2 pings?

#

no

#

i pinged once

paper sluice
slate swan
#

channel ded from 1 hour

sullen pewter
#

how to check dpy version

hazy oxide
boreal osprey
slate swan
tropic burrow
#

my lockdown command does not work
code:

@client.command()
@has_permissions(manage_channels=True)
async def Lockdown(ctx):
    mbed = discord.Embed(
        title="Channel on Lockdown",
        description=f"{ctx.channel.mention} is now in lockdown"
    )

    await ctx.channel.set_permissions(ctx.guild.default_role, send_message=False)
    await ctx.channel.send(embed=mbed)


@client.command()
@has_permissions(manage_channels=True)
async def Unlock(ctx):
    mbed = discord.Embed(
        title="Channel Unlocked",
        description=f"{ctx.channel.mention} has now been unlocked"
    )

    await ctx.channel.set_permissions(ctx.guild.default_role, send_message=True)
    await ctx.channel.send(embed=mbed)



load_dotenv()

client.run(os.getenv('TOKEN'))

my error is: raise CommandInvokeError(exc) from exc nextcord.ext.commands.errors.CommandInvokeError: Command raised an exception: InvalidArgument: Invalid permissions given to keyword arguments.

thin raft
#

commands.has_permissions()

sullen pewter
#

why it isn't sending respone message

#

there's no error

thin raft
#

and the reroll cmd?

lyric berry
#

Im using pycord to develop discord bots, If I have Views in diff files, should I load it in as a Cog?? Or should I just import it as a normal file, and then load em on on_load?

#

on_ready*

maiden fable
#

Is this the whole error?

#

Can u print ctx.respond

#

Like is it a tuple

strong vector
#

await self.bot.process_commands(message)

why i am getting this?

    if origin.author.id == self.user.id:  # type: ignore
AttributeError: 'NoneType' object has no attribute 'id'

i made sure to make members = True

#

your reusing the same code what about creating a func does everything

#

okay your trying to make a whitelist for members who can use ban/kick/etc command?

#

you can check if they have a specific role

#

i don't think you need to do that, but if you want to. i can tell you the steps

slate swan
#

!d discord.User.banner

strong vector
#

1.first create json file
2.create a command to add a new id or add the ids in the json file by yourself
3.use if stm (if the user in the white list then user ban: user.ban else if the user not in the whitelist or the user in the blacklist then ban: author.ban)
explain

@client.command()
async def ban(ctx, user:discord.Member):
    whitelist = load("whitelist.json") # a func to load json : not a build-in func you must create a func by yourself
    blacklist = load("blacklist.json") # a func to load json file "blacklist"
    if ctx.auther.id in whitelist:
        ...
    else:
        ...

whitelist json file will have some ids same with blacklist file
json

[
    09347,
    90237530,
    0238257
]
#

no problem

clever hamlet
#

can someone help me with this error pls

    from discord.utils import get
ModuleNotFoundError: No module named 'discord.utils'; 'discord' is not a package
thin raft
#

dont use get ong

slate swan
strong vector
#

did you had any errors or problems?

slate swan
#

@strong vector

clever hamlet
thin raft
#

what are you trying to do?

strong vector
clever hamlet
#

making discord bot

slate swan
strong vector
slate swan
#

@strong vector

slate swan
clever hamlet
#

im using sublime

stuck oyster
clever hamlet
#

it doesn't give a shit now

#

i mean

#

it doesn't give a error now

#

thx :>

strong vector
thin raft
#

i dont hink is even a thing

slate swan
#

like this

slate swan
strong vector
slate swan
copper gulch
#

idk what's wrong with my code

#

this is the code

#

it's saying line 37, at the part of the command prefix

#

it doesnt work at heroku, but when I run it on pycharm or replit, it works

slate swan
#

because you have discord.py 1.7.3 on your pycharm or repliy and 2.0 on heroku

copper gulch
#

ohh

thin raft
#

@copper gulch

copper gulch
#

lemme change the requirements of it then

thin raft
#

but from your bot

regal pulsar
copper gulch
#

what's wrong though

#

i have it desame too

copper gulch
regal pulsar
#

just enable it

thin raft
#

nono

#

if you enable intents in developer portal

regal pulsar
#

doesnt hurt if your bot isnt verified

thin raft
#

you will also need to add them in your code

regal pulsar
#

well yeah

#

it takes like 2 lines

copper gulch
#

but my code works in pycharm, but not in heroku

regal pulsar
#

pycharm and heroku are 2 completely different things

#

heroku is for hosting and pycharm is a code editor

copper gulch
#

ohh, and now heroku wont let me install discord 1.7.3 instead

#

it only wants 2.0

thin raft
#

use 2.0 is better

copper gulch
thin raft
#

wtf is that

copper gulch
thin raft
#

nono

#

wtf are you doing there

#

send whole file

copper gulch
#

nvm, Ill just stick to replit for now

slate swan
#

in 2.0 you need to pass the intents explicitly

thin raft
copper gulch
#

something like this?

thin raft
#

wdym

strong vector
strong vector
slate swan
copper gulch
strong vector
slate swan
#

How can I give different messages for different option selected in select option?

#

For e.g:
If user selects “a” bot sends “b”
If user selects “1” bot sends “2”

stuck oyster
slate swan
#

Any help?

thin raft
#

await ctx.send(embed = embed)

fleet sand
#

The table is not found. How to solve this?

#Create member database
@bot.command(name = "create", help = "To input your character into our database.")
@commands.has_role("member")
async def update(ctx, input_username, input_data):
    await ctx.message.delete()
    try:
        sqliteConnection = sqlite3.connect("data_sqlite.db")
        cursor = sqliteConnection.cursor()
        print("Successfully Connected to SQLite")
        sqlite_insert_query = """INSERT INTO "table" (key, username, data) VALUES (message.author.id, input_username, input_data)"""
        count = cursor.execute(sqlite_insert_query)
        sqliteConnection.commit()
        print("Record inserted successfully into database", cursor.rowcount)
        cursor.close()
        await ctx.send("Your data has been created in our database. Thank you.", delete_after = 5)
    except sqlite3.Error as error:
        print("Failed to insert data into database", error)
        await ctx.send("There is an error while creating your data. Please try again.", delete_after = 5)
    finally:
        if sqliteConnection:
            sqliteConnection.close()
            print("The SQLite connection is closed")
thin raft
#

open db outside function

slate swan
#

message.author.id
is ctx.author.id

thin raft
#

and for the error remove "" from table

slate swan
fleet sand
thin raft
#

before anything have you created the table?

fleet sand
thin raft
#

he had sent embed not embed = embed

slate swan
thin raft
#

no need for code Ashley V

fleet sand
slate swan
slate swan
#
import requests
import disnake
from disnake.ext import commands
from yadps.config.data import Data

class BookMark(commands.Cog):

    data = Data()

    def __init__(self, bot):
        self.bot = bot

    @commands.Cog.listener()
    async def on_ready(self):
        pass

    @commands.command()
    async def bm(self, ctx: disnake.CommandInteraction, name):
        await ctx.send(name)
    
def setup(bot):
    bot.add_cog(BookMark(bot))

i got this command, but it doesnt work, i am using disnake, the bot doesnt respond to the command, i have all intents on

#

the cog is being loaded since the on_ready function works fine

thin raft
#

does it send the message?

slate swan
#

it doesnt do anything

#

thats not even a thing

fleet sand
slate swan
#

doesnt work without it too

strong vector
slate swan
#

is the cog loaded? do you have an on_message "event"?

slate swan
unkempt canyonBOT
slate swan
slate swan
#

@bot.event or on_message inside the Bot subclass without a process_commands

slate swan
strong vector
slate swan
strong vector
strong vector
# slate swan whats origin?
"Python39\lib\site-packages\discord\ext\commands\bot.py", line 1261, in get_context
    if origin.author.id == self.user.id:  # type: ignore
AttributeError: 'NoneType' object has no attribute 'id'
slate swan
slate swan
#

yoo that works

slate swan
strong vector
# slate swan show code?
    async def on_message(self, message):
        for webhook in self.webhooks.children:
            self.webhookObject(webhook)
        print('Message from {0.author}: '.format(message))
        print("Message from {0.author}:{0.author.id}[\"{0.content}\"]".format(message))
        print(message)
        ctx = await self.bot.get_context(message)
        print(ctx)
slate swan
#

is this a new thing? i dont remember this being like half an year ago

slate swan
strong vector
slate swan
slate swan
#

i am damn sure i didnt need it before

#

maybe you never subclassed with on_message earlier?

#

probably

#

hii, could anyone help with how to make a modmail bot??

#

😄 yes sure

#

thank youu

slate swan
slate swan
strong vector
slate swan
strong vector
slate swan
# slate swan new to it

i would suggest you to look into Object Oriented Programming concepts and asyncio before starting with it

strong vector
# maiden fable Can you show the whole error?
Ignoring exception in on_message
Traceback (most recent call last):
  File "C:\Users\brain\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 375, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\brain\Desktop\progrem use\Tests\python edit packs\DisWebhooker\commands\webhook.py", line 180, in on_message
    ctx = await self.bot.get_context(message)
  File "C:\Users\brain\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 1261, in get_context
    if origin.author.id == self.user.id:  # type: ignore
AttributeError: 'NoneType' object has no attribute 'id'
shrewd apex
slate swan
maiden fable
slate swan
#

and guessing by the file name, you are probably doing it..

strong vector
slate swan
slate swan
#

on_message event or a command would be ideal for this

strong vector
slate swan
#

someone said the whole code is here

#

so idrk

#

it is , @novel apex is open source irrc

#

oh, where is it?

#

which file should i open?

strong vector
#

i am dum af it was the bot.user i was try to fix this like for 3 hours 😂 😭 🥲 i have confusing feelings right now

strong vector
#

how do i fix this?

slate swan
#

btw is this type hint correct

fading harness
slate swan
#

oh

slate swan
slate swan
slate swan
slate swan
regal pulsar
#

someone else sent it here for help

slate swan
#

And wth happened here?

regal pulsar
slate swan
#
@client.command()
async def hello(ctx):
    await ctx.send("hello", components = [
        [Button(label="Hi", style="3", emoji = "🥴", custom_id="button1"), Button(label="Bye", style="4", emoji = "😔", custom_id="button2")]
        ])
    interaction = await client.wait_for("button_click", check = lambda i: i.custom_id == "button1")
    await interaction.send(content = f"{await ctx.send(embed=embed)}", ephemeral=False)

code ^

strong vector
slate swan
#

you sent the complete message object

regal pulsar
#

its ctx: commands.Context

slate swan
#

thanks 👍

regal pulsar
#

np

fading harness
nova stag
#

hey

slate swan
#

^ 3rd party libs are bad, and outdated as for now

fading harness
#

use dpy v2 instead

regal pulsar
#

yes

regal pulsar
slate swan
regal pulsar
#

i tried discord slash once

strong vector
fading harness
nova stag
slate swan
#

*, name

fading harness
#

!docs discord.Guild.create_role

unkempt canyonBOT
#

await create_role(*, name=..., permissions=..., color=..., colour=..., hoist=..., display_icon=..., mentionable=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Creates a [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") for the guild.

All fields are optional...
supple thorn
slate swan
#

and create_role takes a keyword argument "name". its not positional

regal pulsar
#

name=name

slate swan
#

suggest me bot ideas :?

paper sluice
#

server clonner

slate swan
#

V2.0

paper sluice
#

can u make servers with bots?

slate swan
slate swan