#discord-bots

1 messages · Page 544 of 1

slate swan
#

I'm just learning to code

boreal ravine
#

did u try b!purge 10

slate swan
#

bot.run()

#

?

boreal ravine
#

he has that

slate swan
#

oh wait I'm dumb

sick birch
slate swan
boreal ravine
#

u sure

#

any errors?

lament mesa
#

typehint amount with int

boreal ravine
slate swan
lament mesa
#

do you have any errors?

slate swan
#

no

#

impossible

#

have you tried b!purge ?

slate swan
#

without a number

#

why star

#

and then use ur command :3

slate swan
# slate swan no

Have you tried to see if the bot sends any messages with the command?

#

is the bot even online...

slate swan
slate swan
slate swan
#

U got no errors?

#

not one

#

how :|

#

debug it then

#

add a print statement right above your .purge

#

see if it prints

#

Thats what i said

#

if it doesn't then your command isn't even being called

hasty iron
#

add prints everywhere

boreal ravine
slate swan
sick birch
#

can we see the code?

#

for the command

slate swan
#

oh god

#

that's why

#

replace @bot.event with @bot.listen()

#

and it will work :)

#

^

boreal ravine
#

it checks every message

#

right

slate swan
#

ok I will try that

slate swan
#

I have no idea why because I haven't read the source code

#

bot on_message with @bot.event won't process commands

hasty iron
#

bot.listen appends to bot.extra_events

slate swan
#

only if you put bot.process_commands(message)

#

Thx

hasty iron
#

bot.event uses setattr on the client

#

which overrides the default on_message

slate swan
#

K

slate swan
hasty iron
#

yea

slate swan
#

makes sense

slate swan
#

👏

#

Thank you very much!!

gloomy quest
#

how to fix object has no attribute keys

slate swan
#

don't use keys attribute

hasty iron
#

just fix it

gloomy quest
waxen granite
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

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

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

hasty iron
#

or add the keys attribute to the object

#

easy enough

slate swan
#

or what you did

gloomy quest
#

if "responding" not in db.keys():

#

thats the line

hasty iron
#

very helpful

slate swan
#

well what's db

hasty iron
#

we clearly know what db is

slate swan
#

attitude

gloomy quest
#

lol

#

so whhat's wrong

slate swan
#

no idea

gloomy quest
#

the same code works fine in repl

#

but wont in vs code

slate swan
#

what's db

gloomy quest
#

database i think

hasty iron
#

oh its replit’s db

gloomy quest
#

oh

hasty iron
#

it’s just json on steroids

slate swan
#

oh

gloomy quest
#

so how to import their database to my vs code

slate swan
#

well I don't think you can connect to replit's db in VSC

hasty iron
#

ofc it wont work outside replit

gloomy quest
#

damn it

slate swan
#

managed to figure out everything from nothing

hasty iron
#

just use an actual database

gloomy quest
slate swan
#

you can't

gloomy quest
#

lol

slate swan
#

but bot profile's usually get edited in the dev portal

#

just like you can't change the bot's name from code

gloomy quest
#

so about my problem

#

😭

slate swan
#

"use an actual db" was the right answer

gloomy quest
#

yeah but how

slate swan
waxen granite
#

help pls

slate swan
#

without being able to use a database, your programming career wouldn't go anywhere

gloomy quest
#

which other database can i use that wont ruin the code

slate swan
#

every single one of them

hasty iron
#

no database

slate swan
#

nothing would ruin the code

gloomy quest
#

yeah but for this specific bot

hasty iron
#

replit’s db is shit

gloomy quest
#

ikr

slate swan
#

replit overall

gloomy quest
#

lol

#

yall hate replit so much

slate swan
#

maybe SQL

#

because it's shit

hasty iron
#

you would have to rewrite your code to adapt to the new db u choose

lament mesa
slate swan
#

it's potentially the most loved db

#

any SQL

#

or NOSQL (like mongo)

#

postgres is just a really good database

lament mesa
slate swan
slate swan
#

even nosql databases are described with not being sql

waxen granite
slate swan
#

what do you think of that huh

gloomy quest
#

ok thx guys

#

for the help

waxen granite
#

note the what it prints and what it sends

#

there is a lot of difference

shut axle
#

How can I see the member permissions?

embed.add_field(name="User Permissions:", value=member.guild_permissions, inline=False)

This is not working...

kindred epoch
waxen granite
shut axle
#

@waxen granite may you help me please?

shut axle
#

?

#

what do you mean?>

waxen granite
#

do u have member intents as true?

slate swan
#

why wouldn't it work

kindred epoch
#

wait nvm

waxen granite
#

its in the code

shut axle
#

@slate swan actually it is working but...

#

I want the list of the permissions.

slate swan
#

yeah, as the docs say it returns a discord.Permissions

#

you can apply list() on it

shut axle
#

member.guild_permission.list()

narrow cloud
slate swan
#

or just iterate over it directly

shut axle
kindred epoch
#
for channelid in channelList:
                    channel = self.bot.get_channel(channelid)
                    limit_msg += f"     **Channel:** {channel.mention} | **Channel ID:** `{channel.id}`\n"   
                    print(limit_msg)                 
                if len(limitmsg) + len(limit_msg) < 2000:
                    limitmsg += limit_msg
                else:
                    limitmsglist.append(limitmsg)
                    limitmsg = limit_msg 
``` @waxen granite shouldnt you be sending it after you print it
narrow cloud
# narrow cloud

So if i have a bot with slash commands only i can add it to servers ??

slate swan
#

list(member.guild_permissions) basic python smh

waxen granite
kindred epoch
waxen granite
kindred epoch
#

like put print before the last if statement

waxen granite
#

here?

kindred epoch
#
print(limitmsglist)
for limitmsg in limitmsglist:
    await ctx.send(limitmsg)
``` there
waxen granite
#

okay

gloomy quest
#

what database would u guys recommend as an alternative to replit's database

slate swan
#

MongoDB

#

Also questions like this should be asked in #databases

gloomy quest
#

ok

#

sorry

waxen granite
#

@kindred epoch well it prints only what it sends

#

seems to be somethng wrong with append i guess

#

idk what tho

willow vine
#

is there a way we can add a function to the bot as well

narrow cloud
#

I sent a picture

kindred epoch
waxen granite
gloomy quest
kindred epoch
waxen granite
#

but it is not complete msg

#

i want it to send all the commands/stuff that it can print

kindred epoch
#

yea cuz ur using a for loop?

waxen granite
tender charm
#

Hello, I have problem with command in discord.py, I want help command, but when I create help command like:async def help(ctx): after start program, it will write into console this error:discord.ext.commands.errors.CommandRegistrationError: The command help is already an existing command or alias. But problem is, I dont have anywhere help command, no aliases, no command.. Please help

waxen granite
#

help is default cmd

tender charm
#

Ok, where can I put that? Just in the code?

waxen granite
#

under your bot = commands.Bot stuff

kindred epoch
hallow marlin
tender charm
waxen granite
#

np

#

@kindred epoch any idea on my issue?

kindred epoch
waxen granite
#

well that to avoid the limit no?

#

i am not trying to send all the stuff in a single msg

kindred epoch
#

then why do you want to send it in a single mesasge

waxen granite
#

my issue here is that it sends only half or so of the stuff

kindred epoch
#

then why didnt you say that before? tf

waxen granite
#

but it sends only till coinflip

waxen granite
willow vine
kindred epoch
#

or cuz that ur sending it to fast

waxen granite
#

try sleep?

kindred epoch
#

yea maybe that can help

waxen granite
#

how can i sleep in this case?

shut axle
#

@slate swan How can I make this?
list(member.guild_permissions) this is print the whole permissions and type true or false...

waxen granite
#

use .join()

slate swan
#

It returns an iterable, iterate over it, check if it's true, append to a new list, then apply .join on it

#

Iterating is basic python 😟

waxen granite
kindred epoch
#

ye

waxen granite
kindred epoch
#

then idk

waxen granite
#

:3

#

thanks tho

#

i think i found the issue here @kindred epoch

kindred epoch
#

good

waxen granite
#

i tried lowering the limit of 2000 to 1500 and it send 4 more commands

#

not all yet

#

any idea for it?

kindred epoch
#

change it to 0

waxen granite
#

then it will jsut make it a msg for every cmd

#

api abuse

kindred epoch
#

isnt that what u wanted

waxen granite
#

no...

zenith zinc
#

@boreal ravine my bot is not banned

#

🙂

graceful gorge
#

ghelloooooooooooooooo

#

hiiiiiiiiiiii

#

help me

#

print('hello word) is not working

shut axle
slate swan
#

Bruh

#

I'm not gonna help you with basic python 🤦‍♂️

kindred epoch
#

!resource

unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

graceful gorge
kindred epoch
#

i do but wont

#

not the right channel

graceful gorge
graceful gorge
kindred epoch
outer violet
#

I have a custom welcome message and my bot is in a couple of test servers and whenever someone joins one of the test servers it sends a message in my server when they never joined mine, how do I fix that?

@commands.Cog.listener()
    async def on_member_join(self, member):
        guild = self.client.get_guild(784515826765529098)
        channel = guild.get_channel(784515827319439400)
        await channel.send(f"You made it {member.mention}! Welcome to **{guild.name}**, enjoy your stay 💚")
wicked atlas
#

Just compare the guild ids

slate swan
#

Meaning

#

It always sends to that channel.

outer violet
#

How do I fix it ._.

wicked atlas
#

You should be able to compare member.guild.id, and the id of the guild you are sending the welcome message in

slate swan
#

or do it via channel

#

Name

stone palm
#

what would be the best way to store roles in such a way that its stored in a list like:```json
[
{
"role_name" : "something",
"role_id" : 123
},
{
"role_name" : "something_else",
"role_id" : 456
}
]

reef shell
#

store the role object or id ,ez

stone palm
reef shell
#

as you can get the role by id

stone palm
#

the name and the id

#

i want both under one field

reef shell
#

you have a table for roles?

#

make 2 columns , one for name and one for id

#

id's datatype should be bigint

#

which db are you using

slate swan
stone palm
reef shell
stone palm
#

its similar to json

reef shell
stone palm
#

ok

umbral carbon
#

pickle is better than json??

vestal owl
#

is anyone familiar with the library google trans?

slate swan
#
    raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction

how do i create an error handler for this weird error, i dont even know what it is, my commands work perfectly fine. I dont want it to show up

reef shell
#

you need to add owner_ids in bot's attribute bot.owner_ids

#

!d discord.ext.commands.Bot.owner_ids

unkempt canyonBOT
#

The user IDs that owns the bot. This is similar to owner_id. If this is not set and the application is team based, then it is fetched automatically using application_info(). For performance reasons it is recommended to use a set for the collection. You cannot set both owner_id and owner_ids.

New in version 1.3.

reef shell
#

oh i forgot how to set them , my bad

willow vine
#

i've got a function that i want to use in different cogs in different python files, is there a way i can define it once and use it everywhere

reef shell
#

yes, you need to import it in the files you want to use

slate swan
#

it worked before the new API anyone know why is doesent work anymore?

zenith void
#

can you use github libraries in a discord bot

umbral carbon
#

for python

slate swan
#

Can someone help me, or know how to fix that?

kindred epoch
#

old discord api?

umbral carbon
#

looking at the error

#

i think its something with cogs

#

im not sure im kinda new myself

kindred epoch
#

theres a new discord api?

pale zenith
#

because "could not be loaded" doesn't say much rooMonkaS

kindred epoch
#

ye

#

and idk why you have a cog for every single moderation command

#

and idk why you're removing them to

#

😂

#

only the help command is a default command which you should remove if you dont want it

slate swan
#

discord bot lmao

slate swan
#

imagine not asking for help

final iron
#

👍

lost lagoon
#

do you know how to quit a command

slate swan
#

quit()

manic wing
#

my

#

lord

#

i mean, you're not wrong...

manic wing
slate swan
#

see

#

im not wrong

#

but im not right

#

im just special

#

lmao

zenith zinc
#

i`m start the bot
and
typr
type
something command
but
bot
not
send
message
no error message in console
help
pls

zenith zinc
#

pls

#

i nedd helppppp

#

brooo

manic wing
# zenith zinc WHAT

a) show code
b) stop being overdramatic
c) give backstory (when it didnt work, when it did work)

zenith zinc
#

ok

zenith zinc
#

my bot have 344 lines

manic wing
slate swan
zenith zinc
#

this something of code

manic wing
#

answer the questions.

zenith zinc
#

bot.remove_command('help')

#events

@bot.event
async def on_ready():
  await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name=f'-- w.help --' ))
  print("Bot is ready!")

#user

@bot.command(aliases=["whois"])
async def user(ctx, member: discord.Member = None):
    if not member:  # if member is no mentioned
        member = ctx.message.author  # set member as the author
    roles = [role for role in member.roles]
    embed = discord.Embed(colour=discord.Colour.blue(), timestamp=ctx.message.created_at,
                          title=f":notepad_spiral: Informations of user : - {member}")
    embed.set_thumbnail(url=member.avatar_url)
    embed.set_footer(text=f"Rquested by  {ctx.author}")

    embed.add_field(name=":id: ID:", value=member.id)
    embed.add_field(name=":name_badge: User name", value=member.display_name)

    embed.add_field(name=":house: Create acc :", value=member.created_at.strftime("%a, %#d %B %Y, %I:%M %p UTC"))
    embed.add_field(name=":thumbsup: Joined :", value=member.joined_at.strftime("%a, %#d %B %Y"))

    embed.add_field(name=":raccoon: Roles :", value=member.top_role.mention)
    await ctx.reply(embed=embed)```
slate swan
#

bruh

zenith zinc
#

shutup

slate swan
zenith zinc
#

e

slate swan
zenith zinc
#

maybe problem in too many commands

#

?

slate swan
#

then first test with only 1 command in your bot file, comment all the others

#

just to see, if your bot is responding even to a single command

outer prawn
#

anyone know how to use *members: discord.Member

slate swan
#

@zenith zinc

#

is that ur whole code

#

if so u need to add bot.run("TOKEN")

slate swan
#

hey does anyone have a discord bot that bypasses linkvertise links

#

or knows how to make one

uncut comet
#

hello has anyone got any experience with Cogwatch? im having issues getting it to work path='commands': Root name of the cogs directory; cogwatch will only watch within this directory -- recursively. does this mean that i need to set the name to the folder name where the cogs are contained?

junior terrace
#

hi, i have a command mad of a single word, i wanted to do it made by 3 words, how do i do that

#

like !a b c instead of !a

slate swan
#

?

junior terrace
#

like !launch a coin instead of just !launch for example

kindred epoch
junior terrace
#

ty

junior terrace
slate swan
lunar helm
#

so how does the new discord update apply to dpy

junior terrace
#

but there are some forks that already have them like. diskord.py

fallow mauve
#

im trying to figure out how to add music commands to my bot, and i have the following code:

@bot.command(pass_context=True)
async def join(ctx):
  channel = ctx.message.author.voice.voice_channel
  await bot.join_voice_channel(channel)

and it gave me this error:

Ignoring exception in command join:
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "main.py", line 13, in join
    channel = ctx.message.author.voice.voice_channel
AttributeError: 'VoiceState' object has no attribute 'voice_channel'

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

Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'VoiceState' object has no attribute 'voice_channel'
visual island
#

its voice.channel

fallow mauve
#

still same error

visual island
#

bot.join_voice_channel is not a thing, it's replaced by VoiceClient.connect

fallow mauve
#

ok

#

"undefined name 'Voicebot'"

visual island
#

show code

fallow mauve
#
@bot.command(pass_context=True)
async def join(ctx):
  channel = ctx.message.author.voice.voice.channel
  await Voicebot.connect(channel)
lunar helm
#

how exactly does the code communicate to discord?

kindred epoch
lunar helm
#

he quit

kindred epoch
#

Ye

#

And?

lunar helm
#

no one wana take over

kindred epoch
#

Ye and

lunar helm
#

why do people fork if they could take over the main

visual island
visual island
fallow mauve
# visual island its `await channel.connect()`
Ignoring exception in command join:
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "main.py", line 13, in join
    channel = ctx.message.author.voice.voice.channel
AttributeError: 'VoiceState' object has no attribute 'voice'

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

Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'VoiceState' object has no attribute 'voice'
kindred epoch
#

Are you ok?

#

Oh yea I'll just take over this discord server

#

So eassyyyyyyy

#

Wtf?

lunar helm
lunar helm
#

but people wanna run forks?!

kindred epoch
#

All the ppl he trusts that will keep the lib maintained

#

And its not easy to maintain it

#

Sounds easy

lunar helm
#

how hard is it convert to another fork

kindred epoch
lunar helm
#

if i wanted to continue with my bot

visual island
lunar helm
#

ill need to switch to a fork with dlash

kindred epoch
#

Yes

visual island
lunar helm
#

because its a fork i just gotta change discord to x

fallow mauve
lunar helm
#

and it works right?

kindred epoch
#

I don't get what u mean

lunar helm
#

the dpy code will work

visual island
lunar helm
#

with little to no chanting

#

changing

kindred epoch
#

Yes if you find that kind of a lib

#

Might need to change some things obviously

fallow mauve
fallow mauve
# visual island do I say `voice.voice.join`? Or just `voice.join`

error:

Ignoring exception in command join:
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "main.py", line 14, in join
    await channel.connect()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/abc.py", line 1277, in connect
    voice = cls(client, self)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/voice_client.py", line 199, in __init__
    raise RuntimeError("PyNaCl library needed in order to use voice")
RuntimeError: PyNaCl library needed in order to use voice

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

Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/opt/virtualenvs/python3/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: RuntimeError: PyNaCl library needed in order to use voice

code:

@bot.command(pass_context=True)
async def join(ctx):
  channel = ctx.message.author.voice.channel
  await channel.connect()
visual island
#

pip install pynacl

brave vessel
fallow mauve
lunar helm
#

what if it goes over 1000

#

100

brave vessel
#

You’re running it in the file, do pip install pynacl in the console

visual island
fallow mauve
brave vessel
# lunar helm 100

Well — you ask don’t need to switch to slash commands if you’re building a moderation bot and discord verifies it ( I think )

final iron
brave vessel
#

But otherwise you’ll need to switch to slash commands

#

By April though there will definitely be a dominant fork

visual island
fallow mauve
visual island
lunar helm
fallow mauve
fallow mauve
#

dont know how

visual island
#

how can you install discord then..

#

just pip install pynacl

pale zenith
fallow mauve
pale zenith
#

it kinda does that automatically @visual island @fallow mauve

visual island
#

not the app...

visual island
#

okay then, just do import pynacl

brave vessel
fallow mauve
brave vessel
#

PyNACL is the voice support for discord right?

fallow mauve
#

i gtg for today tho, im getting tired

#

bye

lunar helm
final iron
lunar helm
hasty iron
#

not import pynacl

lost lagoon
#

It wont continue

visual island
lost lagoon
visual island
# lost lagoon

you did message.content.lower() but you're comparing it to a list of strings with uppercase letter in it

lost lagoon
#

ill try that thank you

pliant compass
#

Whats the best library to have Slash commands, Buttons, and Dropdown menus? There are so many.

stable delta
#

I'd recommend discord-components, but that's just my opinion

#

however, it does not have slash commands

#

I generally use a combo of discord_slash and discord-components because of this

visual island
#

why dont you just use one lib?

stable delta
#

tbh cause I'm too lazy to find one that combines all of them since I already am used to both systems :p

slate swan
#

when i do a option with my bots buttons in the help command how can i make it not say "this interaction failed" when i dont wanna do anything for that interaction

stable delta
slate swan
stable delta
slate swan
#

i click the button it changes the page and says interaction failed

#

discord_compenents

#

pycord

#

like how do i say to discord the interaction succseded

stable delta
#

well I'm not an expert on it since I haven't used it much, but you should join their official discord and ask there

slate swan
#

ok

pliant compass
final iron
#

I'm trying to create an error handler for a InvalidBodyForm error. What would the name of it be in commands? As example MissingRequiredArguementand CommandOnCooldown

stable delta
final iron
#

Wdym

stable delta
#

like just create a quick testing code that would invoke that error

#

and just read the console

final iron
#

I know what the error is

#

As I said im trying to create an error handler for it

stable delta
#

and you need like the name of it?

final iron
#

I'm trying to look for the name of it in discord.ext.commands

#

To create a simple if statement

final iron
#

ah

hardy yoke
#
except discord.HTTPException as e:
    if e.code == ....:
        #do something
    else:
        #don't do something?```
You can check for the error code via something like this, invalid form body is `50035` I think
final iron
#

The error code is correct

zinc geyser
#

what are the permission overwrites to manage/read/write to private & public threads? Idk if im blind but i cant find them in the API reference

odd walrus
#

anyone happen to know how do i make it to send specific timezone current timestamp|?

lost lagoon
#

after question 2

stable delta
#
import pytz

utc = pytz.utc
pst = pytz.timezone('America/Los_Angeles')
now = datetime.datetime.now(tz=pst).timestamp()

print (now)
lost lagoon
stable delta
zinc geyser
#

dang

stable delta
#

at least I think

lost lagoon
stable delta
#

don't quote me on that lmao

stable delta
lost lagoon
#

sorry?

lost lagoon
hardy yoke
lost lagoon
#

yes

hardy yoke
#

what about if you type b

lost lagoon
#

same thing

hardy yoke
#

Well that's because you did a there

#

look at your if statement, if a user types a the code doesn't go anywhere

lost lagoon
#

does it not go to else?

hardy yoke
#
                if msg.content.lower() == 'a':
                        await ctx.send('https://i.kym-cdn.com/entries/icons/original/000/027/195/cover10.jpg')
                        score += 15
                        await ctx.send (f'Your social credit score is {score}')
                        await ctx.send('What happened on July 4 1989?\n(a)Massacre\n(b)Nothing\n(c)My birthday\n\n')
                else:```

If a user types `a`, the code stops after that last `ctx.send`
#

No it doesn't

lost lagoon
hardy yoke
quiet smelt
#

how do you detect if a webhook is created?

hardy yoke
# lost lagoon how do i fix that

personal recommendation, you probably can get away without nesting much of anything inside if/else beyond the score += or -+

if x = y:
  await ctx.send(image)
  score += 15
else: 
  await ctx.send(image)
  score -=15
await ctx.send(trivia question)
def check(......
#continue here instead of nesting it inside the else```
quiet smelt
#

!webhook

#

psshh

worthy wagon
#
    @commands.Cog.listener()
    async def on_member_join(self, member):
        if member.id == id:
            await member.ban()
#

Am I just being dumb, or is something wrong with this

slate phoenix
worthy wagon
#

It's just not banning the specified ID that I have for when the account joins

slate phoenix
#

Do you have member intents enabled?

#

also dont use id as a variable since it's a py function

worthy wagon
#

I'm not bruh.

slate phoenix
#

im talking about where you're comparing the id's

worthy wagon
#

you can do that

slate phoenix
#

i know, its just bad practice

worthy wagon
#

????

#

there's no other way to check if the member who joins's id.

#

since on_member_join only takes member

fringe python
#
@client.command()
async def unban(ctx, *, member):

Does anyone know what is the purpose of the "*" in the code?

slate phoenix
#

im talking about this line if member.id == id: im assuming id is a variable unless you just put it in there for now

visual island
visual island
fringe python
#

ohh ok, thank you!

worthy wagon
worthy wagon
visual island
worthy wagon
#

I just tried enabling them bro

#

Not trying to sound rude but this is decently irritating

visual island
#

!intents

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.

visual island
#

just follow this and you're done

worthy wagon
#

That's literally the code I wrote

slate swan
#

Is this possible in discord.py? Also is it against discord TOS?

visual island
slate swan
visual island
vagrant brook
#

He means the id variable

worthy wagon
vagrant brook
worthy wagon
#

😐

vagrant brook
#

Do you have that defined somewhere

worthy wagon
#

bro you're trolling right

vagrant brook
#

No

#

5x5 max I think

visual island
worthy wagon
#

Let me try

unkempt canyonBOT
#

discord/gateway.py lines 377 to 379

'$os': sys.platform,
'$browser': 'discord.py',
'$device': 'discord.py',```
vagrant brook
worthy wagon
worthy wagon
#

now anyway

slate swan
#

h

frosty grail
#

you don't have to import intents from discord if you just ```py
import discord

visual island
#

is it against TOS?

boreal ravine
#

no?

#

how is changing a status against tos

#

common sense

visual island
#

¯_(ツ)_/¯

final iron
#

Thought he meant nuking a server

boreal ravine
boreal osprey
boreal ravine
#

@boreal osprey nice

boreal osprey
#

i used a id though

boreal ravine
#

@boreal osprey show code

boreal osprey
# boreal ravine <@568187794405589022> show code
@bot.command(aliases = ['giverole'])
async def addrole(ctx, member : discord.Member, *, message, id : int):
    guild = ctx.guild
    rolename = discord.utils.get(guild.roles, name = message)
    userid = await bot.fetch_user(id)
    
    await userid.add_roles(rolename)
    await ctx.reply(f"I have added {rolename} to {member.name}!")
#

code

boreal ravine
#

did you read your params?

boreal ravine
#

you have a *

#

so everything after message is gonna be taken in the message param

gloomy quest
#

roles = message.author.roles
role = message.guild.get_role(822985879243980870)
if role in roles:

#

ik im doing something wrong

#

on the first line

visual island
#

you're not

#

at least from what I can see

gloomy quest
#

it say the

#

roles attribute doesnt exist

visual island
#

show error?

gloomy quest
#

ok

pliant gulch
#

You need to make sure that message is actually in a guild, and not a DM

visual island
#

message.author can be User if the member is banned/removed from the guild

pliant gulch
#

Otherwise, author would be a user

visual island
#

or that

pliant gulch
#

And thus have no roles attribute

gloomy quest
#

ok

pliant gulch
#

And it would be simpler just to do if Guild.get_role(id) in message.author.roles

#

Guild being the discord.Guild instance, ex: message.guild

gloomy quest
#

ok thx

boreal ravine
#

why is false a string?

slate swan
#

hi im new to py and was wondering for the console part how would i clear the screen lol

#

i have anscii art ready to put i just need to clear it

visual island
#

userid is not false tho? its [] an empty list

#

probably you meant if bool(userid) == False:

slate swan
silver talon
slate swan
silver talon
vagrant brook
#

Uh just use cls

#

oh wait

wintry shore
vagrant brook
#

It's probably just the bot's name

vagrant brook
gloomy quest
#

thx for your help guys

slate swan
gloomy quest
#

my code works now

#

u guys rock

sick birch
boreal ravine
sick birch
boreal ravine
#

@sick birch it isnt

sick birch
# slate swan oh

once you exit the program, cls on windows will clear the screen

#

it isn't what?

boreal ravine
sick birch
#

oh sorry hard to see the underscore

vagrant brook
#

Python can make command line calls through os module

sick birch
#

you could

#

didn't think of that

#

though it's probably better to not for debugging purposes in the future

sick birch
silver talon
void crane
#

Does anyone know how to fix a bot not leaving a vc

odd walrus
#

is there a way where if i have a command that will loop and wont be stop unless i close the script
is there a method where i can use a command to stop it?

boreal ravine
void crane
#

my bot isnt leaving a vc but my code looks correct? do i have an error

#

The leave command isnt working

boreal ravine
#

@void crane stop copying old tutorials

void crane
#

I fixed it

#

i think

#

I got the code checked and the people said it is fine but it dosent work

boreal ravine
#

errors?

void crane
final iron
#

Or text editor?

#

This is an extremely clear error

#

You need to define them

odd walrus
maiden fable
#

while var:
# set var to False somewhere idk where

sick birch
#

while True isn't an issue as long as you yield back to the event loop in 100ms iirc

visual island
#

while True becomes asynchronous if you await a coroutine inside it

void crane
#

im trying to move it to atom

errant shuttle
#

so how will the code be??

visual island
errant shuttle
jagged aurora
#

Working on a dm ban message

#

but i cant get it to say what server they were banned from

jagged aurora
#

that link is old but idk how to get it to display what server

#
   @commands.is_owner()
   async def testban(self, ctx, member : discord.Member, *, reason=None):
            embedChnl = discord.Embed(title="Member Banned", description=str(member.mention), color=0x00ff00)
            embedChnl.add_field(name="By:", value=str(ctx.author), inline=True)
            embedChnl.add_field(name="Reason:", value=str(reason), inline=True)
            test = "{} | Reason  '{}' ".format(ctx.message.author, reason)
            embeddm=discord.Embed(title="**Banned**", description= "f'You have been banned from ctx.guild_name for {reason}, color=0xff0000)
            embeddm.add_field(name="Appeal at",value="https://forms.gle/jFpJm8DEVTDsYeWe6", inline=True)
            await member.send(embed=embeddm)
            await member.ban(delete_message_days=0, reason=test)
            
            await ctx.send(embed=embedChnl)```
#

kinda got messed up when sending

#

but what would i need to change

slate swan
#

?

jagged aurora
#

just that?

errant shuttle
jagged aurora
#

yeah

#

it formated weird

slate swan
jagged aurora
#

@commands.command() @commands.is_Owner() async def testban(self, ctx, member : discord.Member, reason=None): embedChnl = discord.Embed(title="Member Banned", description=str (member.mention), color=0x00ffe0) embedChnl.add_field(name="By:", value-str(ctx.author), inline=True) embedChnl.add_field(name="Reason:", value-str(reason), inline=True) test = "{} | Reason '{}' ".format(ctx.message.author, reason) embeddm=discord. Embed (title="**Banned**", description= "f'You have been banned from ctx.guild_name for {reason}, color=0xff0000) embeddm.add_field(name="Appeal at", value="https:///forms.gle/jFpJm8DEVTDsYeWe6", inline=True) await member.send(embed=embeddm) await member.ban(delete_message_days=0, reason=test) await ctx.send(embed=embedChnl)

errant shuttle
#

@jagged aurora

jagged aurora
#

yeah

#

still new to this

errant shuttle
#

@jagged aurora u shud have done it like this

@commands.command()
@commands.is_Owner()
async def testban(self, ctx, member : discord.Member,
reason=None):
embedChnl = discord.Embed(title="Member Banned", description=str
(member.mention), color=0x00ffe0)
embedChnl.add_field(name="By:", value-str(ctx.author), inline=True)
embedChnl.add_field(name="Reason:", value-str(reason), inline=True)
test = "{} | Reason '{}' ".format(ctx.message.author, reason)
embeddm=discord. Embed (title="**Banned**", description= "f'You have been
banned from ctx.guild_name for {reason}, color=0xff0000)
embeddm.add_field(name="Appeal at",
value="https:///forms.gle/jFpJm8DEVTDsYeWe6", inline=True)
await member.send(embed=embeddm)
await member.ban(delete_message_days=0, reason=test)
await ctx.send(embed=embedChnl)
slate swan
#

^^

jagged aurora
#

how do i get that code block

slate swan
#

wow, that " before f

boreal ravine
#

!code

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
#

sheeeeeeesh

jagged aurora
onyx geyser
slate swan
#
"f'You ....
``` just remove that `"` before `f`
#

bruh, or just google how to use f-string

#

:)

errant shuttle
jagged aurora
#

lemme test

#

ooooh so it sets the language

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.

dusk pumice
#

Here

jagged aurora
#

nbm

#

i think i know what i did wrong

boreal ravine
unkempt canyonBOT
slate swan
jagged aurora
#

I got it now

slate swan
#

gg

boreal ravine
#

nice

boreal ravine
unkempt canyonBOT
#

Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.

>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."

Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.

lilac latch
#

How to get a server's name?

dusk pumice
#

Hm

lilac latch
#

And also how to get member count

boreal ravine
unkempt canyonBOT
#

property member_count: int```
Returns the true member count regardless of it being loaded fully or not.

Warning

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

Oh Kayle send it

boreal ravine
unkempt canyonBOT
dusk pumice
#

Hmm not ctx

#

Haha

boreal ravine
#

it needs ctx

#

thats the class name

dusk pumice
#

Okay

lilac latch
#

It returns this

boreal ravine
#

did u actually use the class name though

lilac latch
boreal ravine
#

not discord.Guild

dusk pumice
#

You don't need discord.

#

you need ctx

boreal ravine
#

your calling the properties of discord.Guild

lilac latch
#

Oh ok

slate swan
#

hey, how can i get my discord bot to indicate ••• User is typing...

boreal ravine
#

it isnt Guild its guild

lilac latch
slate swan
#

thanks!

#

:)

boreal ravine
#

pls learn how to differentiate class names and how to use them

slate swan
#

yes lmao, he confused Guild class with guild attribute of context

boreal ravine
#

^

slate swan
dusk pumice
slate swan
#

no wait

#

bro, just put it as per your choice

#

💀

#

maybe, before your bot sends the message?

boreal ravine
boreal ravine
slate swan
#

oh

dusk pumice
boreal ravine
#

AttributeError: 'Context' object has no attribute 'trigger'

boreal ravine
dusk pumice
slate swan
slate swan
#

i usually don't remember them exactly ok :>

dusk pumice
# dusk pumice Wait
async with ctx.typing():
    await asyncio.sleep(4)
    await ctx.send("done")

Okay it is ctx.typing

boreal ravine
#

h

dusk pumice
#

And it works to me

#

That code

jagged aurora
#

do yall know how a bot can give a member a role based on their discord status

dusk pumice
#

??

jagged aurora
#

like if they have something in their status it will give them a role and if they take it out it will remove it

boreal ravine
#

use a check

dusk pumice
boreal ravine
#
if "kayle" in member.activity:
    execute the code
jagged aurora
dusk pumice
slate swan
jagged aurora
#

I found something on stackoverflow that does it but i dont know the imports i would need to do so

#

and what would need to be changed on it either

slate swan
dusk pumice
#

Me gotta gi bye

slate swan
#

give me a break

#

yes it's okay

jagged aurora
#

anyone able to help me with give member role based on status?

#

it would be task.loop or client.event im pretty sure

lusty swallow
#

is there any way to limit the embed to 2 per level?

#

like move the url down

#

so it's 2 x 2

boreal ravine
lusty swallow
#

yeah but that moves the jump url to its own line and the video url to the next @boreal ravine

drifting arrow
#

@jagged aurora "on_presence_update" is what you'd want

boreal ravine
drifting arrow
#

Brings back the memories of when I setup my adminlogs ;-;

lusty swallow
# boreal ravine show me ur embed code
embed = disnake.Embed(title=f"{4-n}{prefix[3-n]} Place Winner", description=f"For the {4-n}{prefix[3-n]} place, the winner is {user.mention}.\n", colour=0x00D1BA)
embed.set_author(name=self.bot.user.name, icon_url=self.bot.user.avatar.url)
embed.set_thumbnail(url="link")
embed.add_field(name='Message:', value=f'{"`"*3}{entries[0][6]}{"`"*3}', inline=False)
embed.add_field(name='Vote Counts:', value=f'{"`"*3}{score: ^10}{"`"*3}')
embed.add_field(name='Submission Date:', value=f'{"`"*3}{entries[0][7]}{"`"*3}')
embed.add_field(name='Jump url:', value=f'***[Jump to post]({entries[0][8]})***')
embed.add_field(name='Video url:', value=f'***[Jump to video]({entries[0][5]})***')
lusty swallow
#

what part?

boreal ravine
#

wheres the inline kwarg at jump url

lusty swallow
#

i removed it for now

boreal ravine
#

why

lusty swallow
#

since it's not the solution

lusty swallow
boreal ravine
#

it doesnt

#

show me the one

#

you had when u did that

lusty swallow
#
embed = disnake.Embed(title=f"{4-n}{prefix[3-n]} Place Winner", description=f"For the {4-n}{prefix[3-n]} place, the winner is {user.mention}.\n", colour=0x00D1BA)
embed.set_author(name=self.bot.user.name, icon_url=self.bot.user.avatar.url)
embed.set_thumbnail(url="link")
embed.add_field(name='Message:', value=f'{"`"*3}{entries[0][6]}{"`"*3}', inline=False)
embed.add_field(name='Vote Counts:', value=f'{"`"*3}{score: ^10}{"`"*3}')
embed.add_field(name='Submission Date:', value=f'{"`"*3}{entries[0][7]}{"`"*3}')
embed.add_field(name='Jump url:', value=f'***[Jump to post]({entries[0][8]})***', inline=False)
embed.add_field(name='Video url:', value=f'***[Jump to video]({entries[0][5]})***')
lusty swallow
boreal ravine
#

hm

#

I think you cant

lusty swallow
#

F

jagged aurora
#

yall know how i could make a command that only works in certain discord servers

jagged aurora
#

ok

dusk pumice
#

How can I play a mp3 file in discord voice channel?

#

Like if I have test.mp3 and when I type !play I wana make my bot to play test.mp3 in my voice channel.
(I know how to join my bot to vc.)

#

Please help me

#

And how do I get my python version and print it???

#

I want a program for showing python ver

#

And how can I print user states when I say s?

#

No one here

#

I can't find it on docs

#

Ping to Awnser me.

slate swan
maiden fable
#

!d discord.VoiceClient.play

unkempt canyonBOT
#

play(source, *, after=None)```
Plays an [`AudioSource`](https://discordpy.readthedocs.io/en/master/api.html#discord.AudioSource "discord.AudioSource").

The finalizer, `after` is called after the source has been exhausted or an error occurred.

If an error happens while the audio player is running, the exception is caught and the audio player is then stopped. If no after callback is passed, any caught exception will be displayed as if it were raised.
dusk pumice
#

😮

#

Thank you all!!!

maiden fable
#

!d discord.AudioSource

unkempt canyonBOT
#

class discord.AudioSource```
Represents an audio stream.

The audio stream can be Opus encoded or not, however if the audio stream is not Opus encoded then the audio format must be 16-bit 48KHz stereo PCM.

Warning

The audio source reads are done in a separate thread.
slate swan
maiden fable
#

Uhhh

slate swan
#

Oh you know, my bad KEKL

ionic wadi
#

https://hastebin.com/wuvuneqemo.py

I have an getrole command here, but you can only choose one role. How can I make It possible that after selecting one they can select another one?

boreal ravine
#

yes

#

ok

#
def test(a, b, c, d, e) #these are params
    return a
test(1, 2, 3, 4, 5) #these are args
lilac latch
#

How do I make my bot leave the vc

boreal ravine
#

!d discord.VoiceClient.disconnect @lilac latch

unkempt canyonBOT
#

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

Disconnects this voice client from voice.
boreal ravine
#

hm

slate swan
#

How to delete the button message when the timeout is up?
I tested py async def on_timeout(self): await self.message.delete() and worked it, but I still got this error ```py
Traceback (most recent call last):
File "main.py", line 39, in on_timeout
await self.message.delete()
AttributeError: 'Confirm' object has no attribute 'message'
172.18.0.1 - - [19/Oct/2021 06:33:29] "HEAD / HTTP/1.1" 200 -
Task exception was never retrieved
future: <Task finished name='discord-ui-view-timeout-aa7f1403466ba1a96fab0361ad4dd797' coro=<Confirm.on_timeout() done, defined at main.py:38> exception=AttributeError("'Confirm' object has no attribute 'message'")>
Traceback (most recent call last):
File "main.py", line 39, in on_timeout
await self.message.delete()
AttributeError: 'Confirm' object has no attribute 'message'

silk goblet
#

is there any other way to use / commands on discord bots than the discordbot slash library?

#

so like on_writing?

reef shell
#

!d discord.on_guild_join

unkempt canyonBOT
#

discord.on_guild_join(guild)```
Called when a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild") is either created by the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") or when the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") joins a guild.

This requires [`Intents.guilds`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.guilds "discord.Intents.guilds") to be enabled.
boreal ravine
silk goblet
#
from discord_slash import SlashCommand
reef shell
#

It's the same as dpy2.0 but with slash command support

silk goblet
#

is this a bot?

reef shell
#

It's a library

#

Forked from dpy

silk goblet
#

oh, ok

silk goblet
#

but is there an other way then using any library? So like i implementet a command prefix without using the discord library and i hope this works for slash commands too

slate swan
#

You're using dpy, dpy is a library itself

reef shell
#

You just need to pass slash_commands= True to register all the commands as slash command, but it will take upto one hour

reef shell
#

what are you using then

#

Raw api calls?

silk goblet
#

i didnt import any library yet

#

i am trying to code the bot without any library

slate swan
#

You can't

reef shell
#

you can oooof It'll be a library for urself then

silk goblet
#

i can, it is complicated but

slate swan
#

You'd still need aiohttp along many other libs even if you were to not use any of the existing discord python libs

slate swan
reef shell
silk goblet
# slate swan You can't

why do you think so? Librarys are also coded and i can use different languages so, it is possible

reef shell
#

Like he is making his own discord lib

silk goblet
#

exactly

slate swan
#

Ohh

#

Yeah you can

silk goblet
slate swan
#

Visit discord API docs and use aiohttp to do the requests

silk goblet
#

magic

silk goblet
slate swan
#

Then you can't

silk goblet
#

porbably i can, lets see, but thanks for the entertainment

slate swan
#

You need a way to make requests, you can't do that without a library

silk goblet
#

i can code my whole own library, dont you think so? xd

slate swan
#

You can but you're still going to need imports

reef shell
#

Let us know when you finishoooof

silk goblet
#

i will try to remeber

slate swan
#

😂

ionic wadi
#

How to fix this?

slate swan
#

That doesn't look like a discord lib error

ionic wadi
#

Its from pyblox3

slate swan
#

No clue what that is

#

Is it another discord python lib?

#

Or another dpy fork?

ionic wadi
#

as regular

slate swan
#

Well, 404s mean not found

ionic wadi
#

Oh ok thanks

devout quest
#

pls help me debug

sullen shoal
#

os.environ.get()

#

if the key isn't an environment variable it will be None

devout quest
#

ok

#

what next

inner girder
#

E

slate swan
sullen shoal
#

fix your environment variables

#

nice

gloomy quest
slate swan
#

¯\_(ツ)_/¯

gloomy quest
#

i thought the ghost emoji would be more scarier

devout quest
#
import discord
import os

client = discord.Client()

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

@client.event
async def on_message(message):
  if message.author == client.user:
    return


  if message.content.startswith("$bruh"):
    await message.channel.send("bruh100%")


my_secret = os.environ.get('token')
client.run(my_secret)```
#

like this

sullen shoal
#

yes

#

or os.getenv()

devout quest
#

but still error

sullen shoal
#

what error

gloomy quest
devout quest
#

yeh

boreal ravine
#

3rd party libs buggy sometimes

gloomy quest
devout quest
#

still error

sullen shoal
boreal ravine
#

@devout quest whats the error

boreal ravine
sullen shoal
#

u exposed your token

devout quest
#

yeh

#

idc anyways

gloomy quest
boreal ravine
#

@devout quest ur supposed to put ur key in there

devout quest
#

how

#

yeh

gloomy quest
boreal ravine
inner girder
#
import discord
from discord.ext import commands
import os

client = discord.Client()

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

@client.event
async def on_message(message):
  if message.author == client.user:
    return


  if message.content.startswith("$bruh"):
    await message.channel.send("bruh100%")

client.run(“token”)```
@devout quest
devout quest
#

i put my key in

gloomy quest
sullen shoal
boreal ravine
#

ur supposed to do
bot.run(os.environ["ur key"])

boreal ravine
sullen shoal
#

oh

gloomy quest
inner girder
#

@devout quest try using this

import discord
from discord.ext import commands
import os

client = discord.Client()

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

@client.event
async def on_message(message):
  if message.author == client.user:
    return


  if message.content.startswith("$bruh"):
    await message.channel.send("bruh100%")

client.run(“token”)```

Same thing but easy in my opinion
boreal ravine
#

try creating an env file