#discord-bots

1 messages Β· Page 63 of 1

tawdry tendon
#

bro what

#

?

faint sapphire
#

hi, just a simple question
why is this

from discord.ext import commands

bot = commands.Bot(command_prefix='>')

@bot.command()
async def ping(ctx):
    await ctx.send('pong')
```more preferable than reading message.content

is it because its able to handle multiple commands at the same time with the first option?
silk fulcrum
#

Me neither

torn sail
tawdry tendon
#

wdym

tawdry tendon
silk fulcrum
#

Internet went brrrr

torn sail
tawdry tendon
#
@bot.listen()
async def on_member_join(member):
    wel = discord.Embed(color=discord.Color.magenta(), title=f"Welcome {member.name}!", description=f"Welcome {member.mention} If you don't know the commands type in '.help', this will tell you all the commands. I am a math bot so if you ever need help with math, I am the one to use. I can do other things aswell, test me out in. Enjoy your stay!")
    wel.set_thumbnail(url=f"{display_avatar.url}")
    wel.set_author(name=f"{member.name}", icon_url=f"{display_avatar.url}")
    wel.set_author(name=f"{member.guild}", icon_url=f"{member.guild.icon}")
    await member.send(embed=wel)```
tawdry tendon
silk fulcrum
#

/u200b iirc

tawdry tendon
#

@bot.listen()
async def on_member_join(member):
    wel = discord.Embed(color=discord.Color.magenta(), title=f"Welcome {member.name}!", description=f"Welcome {member.mention} If you don't know the commands type in '.help', this will tell you all the commands. I am a math bot so if you ever need help with math, I am the one to use. I can do other things aswell, test me out in. Enjoy your stay!")
    wel.set_thumbnail(url=f"{display_avatar.url}")
    wel.set_author(name=f"{member.name}", icon_url=f"{display_avatar.url}")
    wel.set_author(name=f"{member.guild}", icon_url=f"{member.guild.icon}")
    await member.send(embed=wel)```
faint sapphire
#

got a question, is it possible to get a user name and tag with just their user ID?

tawdry tendon
silk fulcrum
tawdry tendon
#

i thought

#

and i couldnt process what was wrong

silk fulcrum
#

Then sorry I think you should learn python more. Or maybe something in your thoughts process went wrong. Try rereading the error and looking at your code

#

That is the error you should understand yourself

#

Maybe you need to reread the context of our conversation where I said about display_avatar.url

glad cradle
#

hi

silk fulcrum
#

hi

tawdry tendon
#

?

#

u said use itand i used it

#

works now

#

nvm

#

no it doesnt

#

bro im tired

silk fulcrum
tawdry tendon
#

tell me

silk fulcrum
#

I'm not even home

#

Too much explanation

tawdry tendon
#

tell me a little clue

#

shit

#

i just realised

#

i think

#

yep

#

forgot member.

polar scroll
#

how do i change my bots status by coding?

like " playing with ur heart "

swift pumice
silk fulcrum
#

finally im home

swift pumice
sick birch
unkempt canyonBOT
#

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

Changes the client’s presence.

Example

```py
game = discord.Game("with the API")
await client.change_presence(status=discord.Status.idle, activity=game)
```   Changed in version 2.0: Removed the `afk` keyword-only parameter...
tawdry tendon
silk fulcrum
#

okay @tawdry tendon I won't write an essay to explain that.
I will ask a question:
What was in your mind, so you thought that you should replace member.avatar.url with display_avatar.url and not member.display_avatar.url?

#

oh you figured it out finally..

#

congrats

tawdry tendon
#

yep

#

thank you lol

#
wel.set_author(name=f"{member.guild}", icon_url=f"{member.guild.icon}")```
silk fulcrum
#

ok

#

icon.url

tawdry tendon
#

sorry if you get white hairs because of me

#

ok, thanks

#

it didnt display the guild icon

polar scroll
silk fulcrum
tawdry tendon
#
@bot.listen()
async def on_member_join(member):
    wel = discord.Embed(color=discord.Color.magenta(), title=f"Welcome {member.name}!", description=f"Welcome {member.mention} If you don't know the commands type in '.help', this will tell you all the commands. I am a math bot so if you ever need help with math, I am the one to use. I can do other things aswell, test me out in. Enjoy your stay!")
    wel.set_thumbnail(url=f"{member.display_avatar.url}")
    wel.set_author(name=f"{member.name}", icon_url=f"{member.display_avatar.url}")
    wel.set_author(name=f"{member.guild}", icon_url=f"{member.guild.icon.url}")
    await member.send(embed=wel)```
silk fulcrum
#

you can't set two authors

tawdry tendon
#

oh ye

#

true, i didnt see that

polar scroll
#

what are the different types of discord game activity, i know they are watching, playing, listening, but how do i change them in code?

#

i want to put it like "watching"

wispy spade
#

!d discord.Activity

unkempt canyonBOT
#

class discord.Activity(**kwargs)```
Represents an activity in Discord.

This could be an activity such as streaming, playing, listening or watching.

For memory optimisation purposes, some activities are offered in slimmed down versions:

β€’ [`Game`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Game "discord.Game")

β€’ [`Streaming`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Streaming "discord.Streaming")
polar scroll
#

i want it to show "watching" not "playing"

vestal dagger
wispy spade
#

name is just what you want it to say while type is a discord.ActivityType value

#

type can be a few values which are specified in the docs

polar scroll
#

hmm i see

wispy spade
#

you mean where they are located?

polar scroll
#

yah

wispy spade
wispy spade
# unkempt canyon

the thing I sent earlier also has a more direct link to the Activity area

polar scroll
dim cosmos
#

nothing is complicated

#

the docs are simple & very user friendly

polar scroll
#

then i must be dumb

dim cosmos
#

ur not dumb u just didnt read properly

#

read it again & again until u understand

wispy spade
#

if you have questions about it, you are free to ask (there's also some examples in dpy's github repo if you want to pair it up with the gist)

polar scroll
#

alright

#

whats all this?

dim cosmos
#

subclass

polar scroll
#

how.. do they work

dim cosmos
#

self explanatory

polar scroll
#

ok, before i move on

dim cosmos
#

yes

polar scroll
#

how do i put my token safely on my code

dim cosmos
#

you can do it the way i do it

#

put it in a config file

#

json env whatever

polar scroll
#

i just do bot.run( bot token ) which is not safe

dim cosmos
#

Buddy

#

it's not like someone has a reverse shell on ur system

#

u can use a config file to store the token

polar scroll
#

okay, how do i use a config file?

vestal dagger
#

ye u can save it in another file

dim cosmos
polar scroll
#

mhm, done

dim cosmos
#

open the file & get the token from it in ur code

#

& run the token

vestal dagger
#

file = open("token.txt", "r")
token = file.read()

like this perhaps?

polar scroll
dim cosmos
#

Don't ask me anything json related I don't use json I don't interact with json I don't sniff json I don't read json I will never use json

vestal dagger
dim cosmos
vocal snow
#

There is nothing wrong with json lol

dim cosmos
#

using json as db is as useless as an ashtray on a motorcycle

potent spear
vocal snow
#

yes

#

a lot !!

potent spear
#

F

slate swan
#

πŸ§™β€β™€οΈi use json as permanent cache for a bot

#

yo smart people

#

why isnt this shiz working

#

you should use await self.bot.wait_until_ready() before changing the activity here

potent spear
slate swan
#

im gonna change that

#

its just template because im gonna add more statuses and do it every minute

potent spear
#

also, have you even loaded the cog?

slate swan
#

yep

#

all the cogs get loaded in my cogs file

potent spear
#

well, other than that, just make sure the bot is ready

vocal snow
vocal snow
#

10/15m is a safe range

dim cosmos
#

how about every minute

slate swan
#

i do every minute and its working fine rn

vocal snow
#

Mhm until the api notices your spam and ratelimits you

slate swan
#

how can i see the amount of servers my bot is in?

#

i thought it was len(self.bot.servers)

#

but that didnt work

dim cosmos
#

are you ok

vocal snow
#
REST:
        POST Message |  5/5s    | per-channel
      DELETE Message |  5/1s    | per-channel
 PUT/DELETE Reaction |  1/0.25s | per-channel
        PATCH Member |  10/10s  | per-guild
   PATCH Member Nick |  1/1s    | per-guild
      PATCH Username |  2/3600s | per-account
      |All Requests| |  50/1s   | per-account
WS:
     Gateway Connect |   1/5s   | per-account
     Presence Update |   5/60s  | per-session
 |All Sent Messages| | 120/60s  | per-session```
#

Just subclass it? Wdym

dim cosmos
vocal snow
primal token
dim cosmos
primal token
#

If you know about something like ratelimits why are you wondering about them? just follow them as shown in the reference

vocal snow
#

Ok, so are you unable to subclass it normally?

dim cosmos
primal token
#

Did i stutter?

#

is my grammar incorrect?

vocal snow
#

Show what you tried

torn sail
vocal snow
#

Carefully

slate swan
#

thanks papi

torn sail
#

πŸ‘

faint sapphire
primal token
slate swan
#

πŸ—Ώwhy you guys using heroku now... they are about to end the free plan

faint sapphire
#

my bot works when i host on my RPi but id like to solve the problem on heroku

slate swan
primal token
faint sapphire
vocal snow
#

You aren't even subclassing here pithink

slate swan
#

lmao im jk

vocal snow
#

Please the read the doc

#

It very clearly explains

slate swan
vocal snow
#

All of the part under Inheritance

#

Or watch the Corey Schafer video

slate swan
#

!d reload

#

!d discord.ext.commands.Bot.reload_extension

unkempt canyonBOT
#

await reload_extension(name, *, package=None)```
Atomically reloads an extension.

This replaces the extension with the same extension, only refreshed. This is equivalent to a [`unload_extension()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.unload_extension "discord.ext.commands.Bot.unload_extension") followed by a [`load_extension()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.load_extension "discord.ext.commands.Bot.load_extension") except done in an atomic way. That is, if an operation fails mid-reload then the bot will roll-back to the prior working state.
slate swan
#

thanks

#

u can close now

#

@torn sail

#

sorry for the ping but its not that apparently

#

i tried it and it said 0 so i printed it and it says this

polar scroll
#

Guys, what's the difference between using bot.commands.Bot and client.commands.Bot?

slate swan
#

nothing

slate swan
#

i think he just means whats the difference between client and bot

sick birch
#

In that case quite a bit

#

commands.Bot is a subclass of discord.Client, which means it can do everything that discord.Client can and more, such as command handling

dim cosmos
maiden fable
#

Ngl I still feel amazed and disgusted at the same time, whenever I see how commands.Bot is being implemented

maiden fable
#

Be a chad, make an interaction only bot and host it on cloudflare

tough thorn
#

Quick question about discord bots, how do you promote one after making it?

faint sapphire
#

cloudfare free?

im hosting bots on my raspberry pi, but when i cant run my pi for a day or 2 id like an alternative

dim cosmos
#

for some reason everyone uses the logic "new bot that idk of = nuker"

maiden fable
tough thorn
maiden fable
#

That means, only slash, user and message commands

dim cosmos
#

maybe linode

dim cosmos
#

you have SO MANY options other than heroku

tough thorn
maiden fable
#

Ngl I still appreciate those people who still invite unverified bots

dim cosmos
#

someone told me to keep asking people to add it

faint sapphire
#

@maiden fable i didnt rly get what u said

maiden fable
#

Especially mod ones

faint sapphire
#

i invite all sorts of bots

maiden fable
faint sapphire
#

ive invited around 200 bots πŸ‘

dim cosmos
#

my bot is private rn because i barely have an hour a day on my pc and nobody adds it

maiden fable
#

Nice
I don't really own any servers, so idrc anymore

dim cosmos
#

so there's no point in pushing out good updates & adding nice features

maiden fable
#

Ha, it took my bot more than half an year to reach the 100 servers mark

dim cosmos
#

it took my bot 3 months to hit 11 servers

faint sapphire
#

u need a niche community

dim cosmos
#

all being inactive and under 100 members

#

i gave up a long time ago

maiden fable
#

A start is a start @dim cosmos

faint sapphire
#

my bot is around a roblox game
and got asked like 50 times by ppl who want to add it

maiden fable
#

Happened with my bot too, but I never made my bot to leave those

dim cosmos
#

i deleted my old account

tough thorn
dim cosmos
#

bot was in 22 servers on that

faint sapphire
dim cosmos
maiden fable
#

Haha

dim cosmos
#

🐐🐐

faint sapphire
#

ok lol

dim cosmos
#

naw nrn

tough thorn
#

Oh really tysm this will be its 40th server

dim cosmos
#

its offline

faint sapphire
#

dm it to me
i can add them in a few servers

dim cosmos
#

alr thanks

tidal hawk
faint sapphire
#

lol ok

tidal hawk
#

i want to see how chaotic it is

faint sapphire
#

lmfao

tough thorn
dim cosmos
tough thorn
tidal hawk
#

lmao

dim cosmos
#

atleast 5 bots have that prefix

maiden fable
faint sapphire
#

lol

#

bot library lmfao

tough thorn
#

What about !help lol

#

It probably feels like a spam

faint sapphire
#

but i removed perms on many cause indeed its too chaotic when im using a command

dim cosmos
#

anyone familiar with the lastfm api

faint sapphire
#

the strategy was for ppl to see a bigger number of online members on disboard lol

maiden fable
polar scroll
#

Is there a Js server that has a discord bot channel in it?

maiden fable
tidal hawk
#

@faint sapphire waiting for the invite xd

dim cosmos
#

should i open source my bot considering no one is gonna use it & there's no tutorial on how to do 70% of its features

faint sapphire
#

dm it to me

#

if u didnt send here

maiden fable
dim cosmos
#

yea

tidal hawk
#

no i'm waiting a invitation to the server where's 200 bots

slate swan
#

How are ya doin hunter

dim cosmos
#

it would make the bot more trustable but i don't really wanna give away the src

maiden fable
#

Doing fine, was just going to sleep

slate swan
tough thorn
slate swan
dim cosmos
#

it's a private bot rn

#

for my own personal use

#

i use it js for lastfm commands so i don't have to suffer looking for servers with bleed bot or fmbot

polar scroll
#

How do I check general user info with a command?

dim cosmos
#

wym

tidal hawk
#

wym

dim cosmos
#

userinfo/whois command?

polar scroll
#

Yes

dim cosmos
#

dude that's so simple it's embarrassing that you're asking for help w it

#

!d discord.Member

unkempt canyonBOT
#

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

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

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

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

hash(x) Returns the member’s hash.

str(x) Returns the member’s name with the discriminator.
dim cosmos
#

!d discord.User

unkempt canyonBOT
#

class discord.User```
Represents a Discord user.

x == y Checks if two users are equal.

x != y Checks if two users are not equal.

hash(x) Return the user’s hash.

str(x) Returns the user’s name with discriminator.
tidal hawk
dim cosmos
#

DISNAKE

polar scroll
dim cosmos
#

NOOOOOOOOOOOOOOOO

tidal hawk
#

THIS 🐍

dim cosmos
#

BUDDY

#

DISNAKE IS ASS

#

SWITCH TO DPY NOW

tidal hawk
#

WDYMM

#

WDDYMM

polar scroll
#

Thoughts on Pycord?

dim cosmos
#

IM GONNA SCREAM & WAKE UP MY FAMILY & HOSTAGES

dim cosmos
tidal hawk
#

BRO WHATS WRONG WITH DISNAKE

dim cosmos
#

EVERYTHING

tidal hawk
#

NNO

#

YOU DO NOT KNOW WHAT YOU'RE TALKING ABOUT!!!!

polar scroll
#

The sarcasm

dim cosmos
#

BUD

tidal hawk
#

YEAH?

dim cosmos
tidal hawk
#

SHUT YA ASS UP

dim cosmos
#

NOPE

tidal hawk
#

TELL ME WHY ITS BETTER

#

WAITING

dim cosmos
#

BETTER IN EVERY WAY SHAPE & FORM

#

Ok let's accept preferences

#

I'm too lazy to prove a point on discord.com at 12:38 am

vestal dagger
tidal hawk
polar scroll
#

Why is Disnake better then?

tidal hawk
#

biggest w in my life when i moved from py to disnake

dim cosmos
#

i want pizza

tough thorn
#

Wow my bot just got added to like 4 new servers! Idk who but thanks guys ❀️❀️

tidal hawk
#

YEAH?

dim cosmos
#

KI||SS|| U

tidal hawk
#

πŸ’

dim cosmos
tough thorn
polar scroll
tough thorn
tidal hawk
#

it was like 10 months ago

polar scroll
sick birch
#

More support for discord.py, but there are plenty folks who know disnake too

polar scroll
#

Which one is more "beginner friendly"?

#

By that, i mean support wise

sick birch
#

But discord.py themselves said they aren't a "beginner friendly" library

faint sapphire
sick birch
#

If we go by that, none of the discord.py forks are either because the core components and a lot of implenentation details are inherently not beginner friendly due to stemming from discord.py

slate swan
sick birch
polar scroll
#

So should I move to Disnake?

dim cosmos
sick birch
dim cosmos
#

keep learning dpy

#

mess around with shit & practice

sick birch
#

I'm gonna have to disagree

#

learn what you want to, if you're bored, learn disnake because why not

dim cosmos
#

yea

#

still despise disnake 🀒🀒

tidal hawk
#

shut ya ass up

polar scroll
#

Honestly, i just wanted to have a "horizon" to look at, with dpy i have no idea what am I doing I'm just lost

potent spear
#

Just start with the examples and go from there

sick birch
#

Well using another fork isn't going to magically change that

tidal hawk
#

doesn't matter which one you take, both are going to be head ache

primal token
dim cosmos
#

personal preference

primal token
#

If you despise a library so much for no reason and if you do have a reason, the idea of making a discord api wrapper should come up

primal token
torn sail
primal token
#

?

dim cosmos
tidal hawk
#

things got personal

random cairn
#

Heyyyy! So I made a discord bot for my Minecraft server, and I’m trying to get a !start command working. I can’t figure it out for the life of me tho. I just need the bot to be able to run a .cmd file in a new command prompt window (:

dim cosmos
#

reading chinese

random cairn
#

No .cmd

tidal hawk
#

xd

dim cosmos
#

.cmd is .bat

random cairn
#

._.

sick birch
#

I'm not familiar with that format but I'm guessing they're the same

random cairn
#

Yeah lol

primal token
# dim cosmos dude its not literal why did u get offended

I currently want to have a discussion about it, if you have an opinion that goes against other users opinion without having any info to back your statements, why bring it up? youre just giving other users info to spread about the lib that are subjective or incorrect? you can have your own opinion but despising a lib for no reason is just non sense

sick birch
#

You could use os.sytem() to launch it, but I'm hearing that it's not recommended

#

!d os.system

unkempt canyonBOT
#

os.system(command)```
Execute the command (a string) in a subshell. This is implemented by calling the Standard C function `system()`, and has the same limitations. Changes to [`sys.stdin`](https://docs.python.org/3/library/sys.html#sys.stdin "sys.stdin"), etc. are not reflected in the environment of the executed command. If *command* generates any output, it will be sent to the interpreter standard output stream. The C standard does not specify the meaning of the return value of the C function, so the return value of the Python function is system-dependent.

On Unix, the return value is the exit status of the process encoded in the format specified for [`wait()`](https://docs.python.org/3/library/os.html#os.wait "os.wait").
random cairn
#

I couldn’t get that to work

#

something like could not access jarfile

sick birch
#

Oh, you're trying to launch a jar file?

random cairn
#

Via a .cmd yes

sick birch
#

Okay, I'm slightly familiar with this as I've self hosted a MC server before, you have the .cmd file running a .jar file correct?

random cairn
#

A .py to run a .cmd to run a .jar

#

Lol

sick birch
#

Yeah it's a bit strange haha

faint sapphire
#

hey, i host my bot on my raspberry pi, but when i cant im tryna use heroku

my main doesnt have enough free dyno hours
so i made an alt, its connected to the same git repo
it doesnt work tho
when they shut down ur acc, do they blacklist the repo as well?

random cairn
faint sapphire
#

i cant even read but that sounds hilarious

sick birch
faint sapphire
#

better discord is against TOS

#

lmfao i should shut up

#

i confuse users 😭

random cairn
faint sapphire
sick birch
#

From what you've said, I'm gathering it's a pathing issue

faint sapphire
#

ok not basic idk what it is

unkempt canyonBOT
#

Hey @random cairn!

It looks like you tried to attach file type(s) that we do not allow (.cmd). We currently allow the following file types: .gif, .jpg, .jpeg, .mov, .mp4, .mpg, .png, .mp3, .wav, .ogg, .webm, .webp, .flac, .m4a, .csv, .json.

Feel free to ask in #community-meta if you think this is a mistake.

random cairn
#

):

sick birch
sick birch
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.

full lily
sick birch
#

They were getting an error of the .jar file not being found, which led me to believe there's a pathing issue inside the .cmd

random cairn
#

java -Xms16384M -Xmx16384M --add-modules=jdk.incubator.vector -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -jar AutoPlug-Client.jar --nogui

primal token
random cairn
faint sapphire
#

howdy

primal token
#

Im not even 1% french

faint sapphire
#

oh u german

sick birch
primal token
sick birch
#

Perhaps try an absolute path?

random cairn
#

uh..

#

m

faint sapphire
# primal token Nope

tbh u have to be one of them, i never heard of someone who isnt french or german

random cairn
random cairn
#

when i double click the .cmd it works fine

sick birch
# random cairn whats that lol

An absolute path starts from your drive (e.g C:, or D:) and points directly to your file. Without it, the starting point is relative to the current working directory

sick birch
#

So when you call the command from your python folder, the CWD is different from that when you double click it

#

A file on my desktop named "test.txt" would have an absolute path of C:\Users\robin\Desktop\test.txt, rather than just test.txt

#

because test.txt would depend on the invocating CWD

random cairn
#

well the .cmd is in the same directory

sick birch
#

Of?

random cairn
#

heres by python bit:

os.system(path)```
sick birch
#

You need to have a similar absolute path inside of the start.cmd

#

Because when you run that, the CWD is the same as your python file, so it expects the .jar file to be in the same directory

random cairn
#

huh.. java -Xms16384M -Xmx16384M --add-modules=jdk.incubator.vector -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -jar C:\Users\Overdrive\Desktop\MINECRAFT_SERVERS\public\AutoPlug-Client.jar --nogui?

sick birch
#

give that a try

faint sapphire
#

hey, i host my bot on my raspberry pi, but when i cant im tryna use heroku

my main doesnt have enough free dyno hours
so i made an alt, its connected to the same git repo
it doesnt work tho
when they shut down ur acc, do they blacklist the repo as well?

white citrus
#

my on_timeout in the view is not working can someone help?

random cairn
# sick birch give that a try

ok 2 things with this:
it ran the .jar, but the .jar is supposed to run a .jar too lmfao
and i kinda ish need it in a separate window

sick birch
random cairn
#

Ok it now runs the other .jar it was in a config file

#

And would there be any other way to do so?

sick birch
random cairn
#

no the running in another window

#

sry

#

i got it! thanks for your help robin. much appreciated. couldnt have done this without yall

slate swan
#

nice

random cairn
#

wait u just joined my smp didnt u lol

slate swan
#

no?

random cairn
#

saw a message in my bot's terminal

slate swan
#

weird...

random cairn
slate swan
#

that's not me

random cairn
#

πŸ—Ώ

primal token
slate swan
#

//\

random cairn
#

4k

polar scroll
#

is there anything wrong with this?

#

it keeps giving me an error on discord doesnt have the module commands

pliant gulch
#

discord.ext

#

discord itself has no commands module but the ext does

polar scroll
#

im still getting errors aaa

mossy jacinth
#

Hey! The website I published my bot to has this in the 'API' to detect who voted for the bot and how can I use it? I am not a professional with API's

polar scroll
#

how can i solve this?

sick birch
random cairn
#

): im back again

#

when my main.py is running in vs code, a new terminal window opens just fine. however, when i open main.py with python instead of vs code, the terminal window doesnt show bruh

slate swan
#

@torn sail still not working

#
class BotStatus(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
        self.status_change.start()

    @tasks.loop(seconds=5)
    async def status_change(self):
        await self.bot.wait_until_ready()
        self.guild_count = 0
        for guild in self.bot.guilds:
            print(f"{guild}")
            self.guild_count += 1
        print(self.guild.count)
        
        self.statuses = cycle([f'I\'m in {self.guild_count} servers', '!help'])
        await self.bot.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name=next(self.statuses)))
    
async def setup(bot):
    await bot.add_cog(BotStatus(bot))```
#

it will print the first guild

#

but wont print the guild_count

#

Isn't there already a built in guild count method?

#

nah

#

cant find it on docs

#
print(f"{len(bot.guilds)}")
#

try that probably

#

thats what i tried lmao

#

but it prints a weird thing

#

two secs

#

.guilds is a list of guilds

slate swan
#

it responds with 0

#

even though its currently in 1

#

weird

#

print bot.guilds

#

thats what im doing two secs

#

printing bot.guilds should show a list of guilds

#

this is the weird thing

#

oh

#

that's from the class

#

what's your actual code

#

you tried

primal token
#

its a sequence object in dpy

#

!d discord.ext.commands.Bot.guilds

unkempt canyonBOT
slate swan
#

What the

primal token
#

in disnake its a list

slate swan
#

Oh

#

listen to noid he knows all

primal token
#

thats a strong incorrect statement

slate swan
#

noid u got a fix?

#

!d discord.Client.guilds

unkempt canyonBOT
primal token
slate swan
#
print(len(list(client.guilds)))
#

or

print(len([guild for guild in client.guilds]))
#

I think.. @primal token ?

primal token
#

servers isnt an attr

slate swan
#

right

#

For self bots, how intents can be enabled ?

slate swan
slate swan
slate swan
primal token
slate swan
primal token
#

yeah

slate swan
#

good

#

Sequences are important and powerful data types in Python. A sequence is an object containing a series of objects. There are three types of built-in sequences in Pythonβ€”list, tuple, and string.

primal token
#

container types lol

frigid apex
#

hello idk where to ask.. i need help checking if file exists and if not creating it

code:

# CONFIG FILE
# CHECK IF config/key.toml DOESN'T EXIST
if os.path.exists("config/key.toml") is False:
    # CREATE config/key.toml
    with open("config/key.toml", "w") as f:
        f.write("key = \"\"\n")
        f.write("key_active = \"false\"")
# CONFIG toml
config = toml.load("config/key.toml")```

error:

Traceback (most recent call last):
File "W:\Github\ValoGuard-Private\valoguard.py", line 50, in <module>
with open("config/key.toml", "w") as f:
FileNotFoundError: [Errno 2] No such file or directory: 'config/key.toml'```

any ideas what the issue is and how to solve?

slate swan
#

w+ Opens a file for both writing and reading. Overwrites the existing file if the file exists. If the file does not exist, it creates a new file for reading and writing.

primal token
unkempt canyonBOT
#

@primal token :white_check_mark: Your 3.11 eval job has completed with return code 0.

Ok
primal token
slate swan
primal token
#

ok

#

sorry, kinda bored lol

slate swan
primal token
#

i should get back at my project lol

#

kek

slate swan
#

!e

print(getattr(__import__("random"),"choice")([1,2]))
unkempt canyonBOT
#

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

2
pliant gulch
#

What was the point of getattr

#

You can just directly access via dotnotation

slate swan
#

🀷

#

!e

print(__import__("random").choice([1, 2]))
unkempt canyonBOT
#

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

1
slate swan
#

same thing

primal token
#

!e

print.__call__(getattr.__call__(__import__.__call__("random"),"choice").__call__(list[int](tuple[int, int].__call__({int.__call__(1), int.__call__(2)}))))
unkempt canyonBOT
#

@primal token :white_check_mark: Your 3.11 eval job has completed with return code 0.

1
primal token
#

allot of __call__pithink

primal token
slate swan
#

🀯

primal token
mossy jacinth
#

Hello! I just learned how to reward users that upvoted but it only works for my main account?

pliant gulch
primal token
#

kek

unkempt canyonBOT
#

@pliant gulch :x: Your 3.10 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | IndexError: list index out of range
primal token
#

double kek

pliant gulch
#

πŸ€”

primal token
#

no but actually wtf bro

glad cradle
#

!e

print(', '.join(str(i) for i in {i*j for (i, j) in [(i, j) for i in range(__import__('random').randint(0, 2), __import__('random').randint(2, 10)) for j in range(__import__('random').randint(0, 2), __import__('random').randint(2, 10))] if i*j%2 == 0}))
pliant gulch
#

It's random.choice but without any imports

primal token
primal token
cold sonnet
#

I started json

#

it's 1595 lines of how much of a king I am in a game

primal token
cold sonnet
#

wtf do I do with this much data

primal token
#

delete it

cold sonnet
#

great idea

primal token
#

πŸ™ˆ

cold sonnet
#

❀️

potent spear
slate swan
#

Non alive chat

sick birch
#

that's good

#

means people are doing well and don't need any help

#

and sometimes i wish this chat was dead when it was alive with the stuff that goes down here

brave hinge
#

does anyone know why i am getting this error?

#

ive copied code from a previos discord bot that works and it still gives me the error

#

this is the current code i have

hazy oxide
#

Turn on ur intents

brave hinge
hazy oxide
#

Go to discord developer portal

brave hinge
#

but it still gives me thhe same error

hazy oxide
#

intents = discord.Intents.all()

brave hinge
hazy oxide
#
client = commands.Bot(command_prefix='?', intents=intents)```
brave hinge
#

it worked!

potent spear
#

remove line 11 btw, it has no use
you either use discord.Client or commands.Bot, not both

potent spear
potent spear
#

so you'll need to toggle some off and also adjust your message intents in the code
more info can be found here
#discord-bots message

strange ocean
#

I am thinking of making some "online since" system that would basically log when a Member's status last changed to "offline" though, that's not really enough, i have to log when a Member with an offline status executes any event, is there any particular event that allows me to do such thing ?
example:

  • a user sets the offline status manually
  • the bot stores it.
  • the user executes any event (message creation, message edit, message deletion, nick change, voice join, mod actions ...) while having the offline status still
  • the bot logs that (the date)

should i have all the events ? or is there a better way to do so

slate swan
#

Good luck ☠️

hollow lantern
#

I keep getting this error, does anyone know how I can prevent this error?The bot is in 2 servers that I own and none of its commands are being used.

wispy spade
#

due to how replit works (it shares your container and so same ip with other people), ratelimits can happen quite often

hollow lantern
#

ah ok

#

what should I switch to

wicked atlas
#

something not free

strange ocean
#

a VPS

wispy spade
#

again, not desirable but it will get you rid of the ratelimits

wicked atlas
wispy spade
#

if you want something decent tho, get a vps

#

or selfhost

wispy spade
wicked atlas
strange ocean
#

sup Tekgar do you have any idea about my question

wispy spade
#

prob other option is railway which is now kinda heroku-like

#

i.e. you got exec limits and things like that

wicked atlas
slate swan
wispy spade
strange ocean
#

zamn

wispy spade
strange ocean
#

i thought i could use on_socket_raw_receive but then i realized it has different formats in each event

wicked atlas
strange ocean
#

im using dpy, yes

slate swan
#

Ask robin @strange ocean

strange ocean
#

who's robin

slate swan
#

He knows a lot

#

@sick birch

sick birch
#

hi

strange ocean
#

Hi robin

sick birch
#

how can i help

strange ocean
#

would be appreciated if you can help

#

im using dpy

sick birch
#

There's no catch all event

pliant gulch
#

If you're only storing date the format of the payload when dispatching can be ignored

sick birch
#

on_socket_raw_recieve may not necessarily be a user did something

strange ocean
#

ye

strange ocean
sick birch
#

Wouldn't it just be easier to log how long a user has been offline? You don't really have to check all the events. That's a design choice though, so up to you

strange ocean
sick birch
#

Know when a user went offline?

strange ocean
#

wouldn't be when he dispatches an event ?

pliant gulch
#

Well it won't be that bad to add all the events because one event could encapsulate others

#

E.g guild_member_update would be presence, voice, nick etc

sick birch
#

Not quite

strange ocean
sick birch
#

Well the time the user goes offline is accurate, but the time the user comes back online is not

wispy spade
#

if you want to check presence changes, ig there's on_presence_update

sick birch
#

They might be in invisible mode, and tweaking settings or whatever and you'd still think they're offline

strange ocean
sick birch
#

Not if you put all of your events in a big cog

pliant gulch
strange ocean
sick birch
#

cogs

strange ocean
pliant gulch
#

I'll write a quick example for you

strange ocean
#

the last time they executed an event would be the online since assigned to them

sick birch
strange ocean
#

no not just messages

#

(message creation, message edit, message deletion, nick change, voice join, mod actions ...)

sick birch
#

I see what you're saying, I'm just suggesting alternates. Catching all the events might be a small PITA but doable

strange ocean
#

ye

wispy spade
sick birch
#

And like andy mentioned many of the events include many other events, so it's not too bad

strange ocean
#

yep i see

strange ocean
pliant gulch
#
class Logger(commands.Bot):
    EVENTS: typing.ClassVar[set[str]] = {
        "MESSAGE_CREATE",
        "MESSAGE_DELETE",
        "MESSAGE_UPDATE"
    }

    def on_socket_raw_receive(self, message: dict[str, typing.Any]) -> None:
        if name := message.get("t"):
            if name not in Logger.EVENTS:
                return

        # do other stuff
``` then from there you could just check the data key tbh
#

But this is pretty low-level (good method if you don't care about the format)

wispy spade
#

preferably there would be a wildcard listener but dpy doesn't have that afaik

strange ocean
sick birch
strange ocean
#

do i just make multiple loggers

sick birch
#

Right discord is pretty consistent about their payloads when they can

sick birch
mossy jacinth
#

Hello! My bot keeps sending things twice, I've tried to reset the Token but it still happened... Then I removed @bot.listen() idk the name of this but after that it stopped sending messages twice. You can see the code I've disabled

strange ocean
#

i will try and see

#

thank you @sick birch , @wispy spade

pliant gulch
#

You must also assume EVERY message's OPCODE to be 0 otherwise it isn't a dispatch in our case

#

It'll have t (name), and d (data) among other keys

strange ocean
#

what makes a message's OPCODE not 0

pliant gulch
#

d will be your raw dictionary, e.g representing a member object

wicked atlas
pliant gulch
#

Then you can get an ID from there

pliant gulch
wispy spade
pliant gulch
#

Like RESUME, HEARTBEAT ETC

mossy jacinth
wispy spade
strange ocean
#

i see

pliant gulch
wicked atlas
# mossy jacinth But im using `@bot.listen()`

Yes, but you still have await process_commands(message) at the bottom. Your bot's on_message event isn't overwritten by @bot.event, so you're actually processing your commands twice.

pliant gulch
#

Since each logger is a client

#

Control flow would be pretty simple here, you can also split it off into other methods bound to Logger

sick birch
#

Oh I didn't even notice you were subclassing commands.Bot

pliant gulch
#

Really the whole point of using that would be to just have ONE entry point

sick birch
#

Can't you stick a listener onto it?

mossy jacinth
pliant gulch
pliant gulch
#

Incase you want to, split it into a callback style of parsing or otherwise

pliant gulch
#

Because your different event listeners will receive different arguments

wicked atlas
wispy spade
wicked atlas
#

You don't need to call it manually

mossy jacinth
#

Ok thanks guys! It works

pliant gulch
#

Wholesome activity from a very interesting name

strange ocean
pliant gulch
#

Yes, t is ALWAYS given when opcode is 0

limber bison
#

How can get running time in text , ?

pliant gulch
#

That means it's dispatched

#

It'll also have d

#

But give me a minute actually, I think I might've gotten a better way of doing this

wispy spade
strange ocean
#

sounds fancy

#

let's hope i don't face unexpected problems

small crag
#

yo do you guys know what the discordutils library is called

i have written import DiscordUtils
its not working

wispy spade
slate swan
slate swan
limber bison
#

Tomorrow it will be 1 day

slate swan
#

do ?tag uptime in the dpy server

wicked atlas
ornate sail
#

is it possible to make it so that my bot live updates when i change a code in vscode

#

like if i save my file it will automatically relaunch the bot in vsc

wicked atlas
#

I usually just ctrl + c, up arrow, enter

ornate sail
#

i've seen that people can do it within the virtual env so idk if its possible

pliant gulch
#

Also cache is just a dictionary so, change that to your needs

#

If you were wondering what the point of doing all that weird stuff in the class, it's to get it into a consistent entry point

#

So, name, payload

#

oooh actually I just realised a massive flaw in the code

sick birch
pliant gulch
strange ocean
#

lol

pliant gulch
#

I guess just go with the simplier way (using multiple cogs with manual event listeners)

#

That'll be the best and most consistent way

strange ocean
#

i appreciate you trying to help me though, thank you for that

#

using multiple cogs huh

#

each cog for what ?

#

each cog for an event listener?

pliant gulch
#

For an example you'd only need ONE cog for all the MESSAGE related events

#

E.g one cog does on_message, on_message_edit, on_message_delete

#

And then another cog does your voice_state_update, and member_update

#

This isn't really necessary you can do it all in one file but it makes it a bit cleaner

strange ocean
#

@pliant gulch one more question, do you think this wouldn't be heavy or resource-hungry for example if i had the bot in a big server where a lot of users execute these events all the time

ornate sail
pliant gulch
#

If you tie this with MANY users it'll most often than not be fired more than you can anticipate it

#

So I would say, decently resource intensive

sick birch
strange ocean
pliant gulch
#

Off the top of my head, no not really

#

Your gonna need the event otherwise the whole thing won't work

#

And the only issue with that is that it'll be dispatched a lot

#

But that makes it un-avoidable

strange ocean
#

ye that's the problem too many events being dispatched a lot of times, wonder why no bot tried to implement it

#

ill try and see

ornate sail
potent spear
#

restarting the bot whenever you save in vsc isn't the best idea, since you'll most likely save somewhere in between when you're going to eat or whatever

#

a better implementation is something like githooks, where once you commit something to your github repo, the bot will restart

ornate sail
#

not forever

potent spear
#

well, your use case stays the same,

#

you definitely don't want to restart a bot whenever you save a file

dim jetty
primal token
#

Because he probably deleted it

shrewd apex
#

hmm yeah but he send it like an hour ago why send if u gonna delete πŸ—Ώ

dull knot
#

If I were to try and make currency cmds, would I require knowledge about File Writing/Reading/Editing?

If so, what cmds should I start working with if I would want to create some Currency cmds?

#

Like, what are some exercises I could do?

shrewd apex
#

or use some nosql db like mongodb

dull knot
#

What're those?

shrewd apex
#

SQL is a rdbms

#

relational database management system

#

mongodb usually atlas is used which is a cloud hosted database which use json formats to store

dull knot
#

So that's where I'll be storing the data?

#

Alright. Will try looking it
Up later. Thx for helpsmeil

ornate sail
#

im literally doing the same thing everytime i wanna check the code

boreal osprey
pliant gulch
potent spear
#

also, how's app_commands defined?

boreal osprey
boreal osprey
# potent spear also, how's app_commands defined?
class MyClient(discord.Client):
    def __init__(self, *, intents: discord.Intents):
        super().__init__(intents=intents)
        self.tree = app_commands.CommandTree(self)


    async def setup_hook(self):
        self.tree.copy_global_to(guild=MY_GUILD)
        await self.tree.sync(guild=MY_GUILD)

yes i have a MY_GUILD object, i just forgot to copy it

potent spear
#

now the FULL file

#

!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.

potent spear
#

also, that init looks off

#

you want to use self, intents, *args, **kwargs

boreal osprey
#
import discord
from discord import app_commands
import asyncio

MY_GUILD = discord.Object(id=1004165949571731536)

class MyClient(discord.Client):
    def __init__(self, *, intents: discord.Intents):
        super().__init__(intents=intents)
        self.tree = app_commands.CommandTree(self)


    async def setup_hook(self):
        self.tree.copy_global_to(guild=MY_GUILD)
        await self.tree.sync(guild=MY_GUILD)

intents = discord.Intents.all()
bot = MyClient(intents=intents)



@bot.event
async def on_ready():
    print('online!')


@bot.tree.command()
async def hello(interaction: discord.Interaction):
    await interaction.response.send_message("hi")


bot.run('token')
#

this is the entire file atm

potent spear
#

you don't have any other forks installed?

boreal osprey
#

something like disnake or pycord? no i dont

potent spear
#

show me

#

pip list

boreal osprey
#

tf

#

discord.py still says it's at 1.7.3 even though i updated

#

hold on

potent spear
#

just delete and reinstall

boreal osprey
#

ok now im back at 2.0.1

#

well, now i am, not back

#

the hell is this supposed to mean

potent spear
#

that's logging...

boreal osprey
#

that is fun to get on my normal bot after updating

#
C:\Users\myname\Desktop\saul goodman\bot.py:29: RuntimeWarning: coroutine 'BotBase.load_extension' was never awaited
  bot.load_extension(f'cogs.{filename[:-3]}')
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
shrewd apex
#

await it

potent spear
shrewd apex
mossy warren
#

When I run this it says I need a library called "pynacl" but when I import it, I get a library not found error

    elif msg.content.lower() == '!join':
      try:
        channel = msg.author.voice.channel
        join = True
      except Exception as c:
        print(c)
        join = False
      if join:
        await channel.connect()
      else:
        await msg.channel.send("You're Not in a VC, !join will only work if You're in a VC")
mossy warren
torn sail
#

Oops forgot

potent spear
maiden fable
#

Mhm

potent spear
#

replit sucks anyways, but most likely, yes

mossy warren
slate swan
#

in the shell

mossy warren
#

also why is it named after sodium chloride?

mossy warren
torn sail
#

!pypi PyNaCl

unkempt canyonBOT
#

Python binding to the Networking and Cryptography (NaCl) library

torn sail
#

Networking and cryptography library

potent spear
#

still not a logical abbreviation

torn sail
#

Yeah but I guess it sounds good

maiden fable
#

First thing that comes to mind is indeed Sodium Chloride

slate swan
#

same πŸ’€

grim oar
#

Names don't have to sound logical bro, I literally name my stuff after anime girls

slate swan
#

name it after your name

mossy warren
primal token
slate swan
grim oar
slate swan
#

breh

primal token
daring olive
#

remove the invite

slate swan
#

MAN IT KEEPS DELETING

#
await bot.wait_for('reaction_add', check=check)```
Can I specify a certain number of reactions before executing the rest of code here?
#

mina pepeShy

grim oar
daring olive
#

remove the invite

slate swan
daring olive
#

or use a paste bin

slate swan
#
2022-08-28 00:41:59 ERROR    discord.ui.view Ignoring exception in view <Paginator timeout=None children=2> for item <next_page style=<ButtonStyle.secondary: 2> url=None disabled=False label='' emoji=<PartialEmoji animated=False name='β–Ά' id=None> row=None>```
primal token
grim oar
#

Ok okimii

primal token
#

dont call me that name nor associate me with it

grim oar
#

Ok

primal token
#

Ok

slate swan
#

okimii? noid is okimii?

grim oar
#

Yes lol, you didn't notice?

slate swan
#

no...

#

where did his previous account go

grim oar
#

Can we move to offtopic

primal token
#

I have literally no relation to okimii -_-

slate swan
#

sure

daring olive
#

i also think you're pretty wrong but

grim oar
#

Ok sorry.

slate swan
#

nova πŸ’€

#

that was funny though

#

but anyways

grim oar
#

That admin scares me, not even kidding

#

Anyways, offtopic.

primal token
#

There should be no reason, thats like being scared of the police

slate swan
#

can someone help me

spring flax
#

what's your question?

daring olive
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.

slate swan
#

discord.gateway Can't keep up, shard ID None websocket is 50.1s behind.

#

and then

#
2022-08-28 00:41:59 ERROR    discord.ui.view Ignoring exception in view <Paginator timeout=None children=2> for item <next_page style=<ButtonStyle.secondary: 2> url=None disabled=False label='' emoji=<PartialEmoji animated=False name='β–Ά' id=None> row=None>
Traceback (most recent call last):
  File "C:\Users\k\Desktop\virl\discord\ui\view.py", line 425, in _scheduled_task
    await item.callback(interaction)
  File "C:\Users\k\Desktop\virl\button_paginator\__init__.py", line 36, in callback
    await interaction.response.defer()
  File "C:\Users\j\Desktop\virl\discord\interactions.py", line 592, in defer
    await adapter.create_interaction_response(
  File "C:\Users\j\Desktop\virl\discord\webhook\async_.py", line 219, in request
    raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction```
#

im using a third party

#

library

shrewd apex
#

in such case u are supposed to defer and then send

mossy warren
#

wtf are indents?

grim oar
#

Spaces or tabs

primal token
unkempt canyonBOT
#

Indentation

Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.

Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.

Example

def foo():
    bar = 'baz'  # indented one level
    if bar == 'baz':
        print('ham')  # indented two levels
    return bar  # indented one level

The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.

Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines

More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation

primal token
#

quite important info you should know about as python depends on it

mossy warren
shrewd apex
primal token
mossy warren
#

its some events thing

primal token
#

!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 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.

grim oar
mossy warren
shrewd apex
#

ok i thought i read it wrong intents as indents

primal token
grim oar
#

Intentions

mossy warren
#

I'm not sure what intentions to configure I don't wanna mess up my thing

primal token
spring flax
#

Intentions to configure?

primal token
#

remove the trailing coma

#

arent slash commands bounded to your bot in nextcord?

glad cradle
#

you're supposed to use your Bot object

primal token
#

then just use cogs?

glad cradle
#

you can do it the same even if it is a subclass

primal token
#

it looks messy especially with the setting up of your bot subclass and commands

shrewd apex
#

why even subclass if u are not using setup hook and want to have all code in just one file Β―_(ツ)_/Β―

glad cradle
#

After the class that subclass command.Bot add bot = MyBot() then use decorators like @bot.command() to add commands

primal token
shrewd apex
glad cradle
#

Nice token

primal token
shrewd apex
#

i find it more organised and neat if i subclass the bot and have the setup hook in there

primal token
shrewd apex
#

indeed u can pithink but i prefer subclassing

primal token
#

you do you ig

#

you should atleast follow the python zen or even better save a few kbs of storage or micro seconds for performance

#

?!??

primal token
#

No someone named asher, ofc it was for youducky_beer

#

i shouldve replied mb

shrewd apex
#

... ok so how does subclassing not follow python zen πŸ₯²

primal token
#

simple is better than complex
you can also save a few bytes by not using as many chars and you can probably increase speed a bit over declaring a whole subclass to overwrite a method

shrewd apex
#

hmm i see

#

omw to memorize python zen

primal token
#

i would say its allot of boilerplate

grim oar
#

subclassing is simple bro

shrewd apex
#

πŸ™

primal token
#

πŸ™ˆ

grim oar
#

🀨

slate swan
#
tmsg = await ctx.send(embed=embed, view=endutton())
    
    await tmsg.add_reaction(":giveaways:")
    f_msg = await ctx.channel.fetch_message(my_msg.id)
    reaction = [r for r in f_msg.reactions if str(r) == ":giveaways:"][0]
    
    sleeptime = duration.to_seconds()
    await asyncio.sleep(sleeptime)

    users = [user async for user in reaction.users() ]
``` how can i mention everyone who reacted to the reaction
#

i mistakenly sent this in databases

slate swan
rugged shadow
#

or you mean in the client

slate swan
#

in the client lol

slate swan
#

what

primal token
#

str.join takes any iterable

#

so just passing the expression is probably fine

slate swan
#

huh

sacred minnow
#
    @commands.command(name="kick", description="Kick a user from the server.")
    async def kick(self, ctx: commands.Context, user: discord.Member, *, reason=None):
        if ctx.author.id != self.bot.owner_id:
            await ctx.send("author id does not match owner id!")
            return
        if reason is None:
            reason = "No reason provided"
        embed = discord.Embed(
            title=f"Kicked user {user.name}",
            description=f"Reason: {reason}",
            color=0xFF0000,
        )
        embed.set_footer(icon_url=user.avatar.url)
        embed.set_author(name=ctx.author.name)
        # await ctx.send("kick command called")
        await ctx.send(embed=embed)```
pliant gulch
sacred minnow
limber bison
#

Why discord forcing dav migrate to slash ?
The end for prefix , that's discord want ?

primal token
#

You do have a point i shouldve specified you can only pass an iterable that passes a str

pliant gulch
#

Weren't you talking about [..., for ... in ...] as a list cast?

sacred minnow
#

i see

primal token
pliant gulch
sacred minnow
#

can it be empty? embed.set_footer(text="", icon_url=user.avatar.url)

primal token
slate swan
#

no wait it cant be empty

sacred minnow
slate swan
sacred minnow
#

she/he πŸ’€

#

nothing

sacred minnow
#

like this? embed.set_footer(text=**, icon_url=user.avatar.url)

sacred minnow