#discord-bots

1 messages ยท Page 866 of 1

hushed field
#

its still slow, adds to the reason you got banned from dpy support

slate swan
#

๐Ÿ’€

dry kelp
hushed field
#

its wick

dry kelp
#

d.py is a pain too .. maya mutin for no reason

slate swan
#

it depends on allot of things ok

#

Bc u claim to be a programmer ur not if u donโ€™t know reasons for separate user prefix

hushed field
#

compare to summrs or any other decent bot

dry kelp
#

summrs slow too.. same with security

#

SUMMRS DECENT?

slate swan
#

bro antinukes are useless lol

dry kelp
#

BRO NICK ADMITTED THAT MY BOT HAS A BETTER ANTINUKE THAN HIS LMFAO

visual yarrow
#

Hello. What's going on here?

hushed field
#

LOL summrs slow? please test your bot against an actual 50+ bans per second nuke

slate swan
#

ok guys

slate swan
sick birch
#

guys please chill out

hushed field
dry kelp
#

i already tested

slim ibex
#

i don't see whats wrong with one guild prefix

slate swan
#

Omfg

#

Can u not fucking read

final iron
#

Inb4 chat gets silenced

dry kelp
#

if the nuker bans 50+ sec my bot will save it at 49 bans

slate swan
#

do you guys know how an api works๐Ÿ—ฟ

slim ibex
#

im just gonna stop typing before i get punished somehow ๐Ÿ—ฟ

hushed field
#

slow blurple_sparkle

dry kelp
#

most of the nukers are getting 1-13

slate swan
visual yarrow
#

!silence

unkempt canyonBOT
#

โœ… silenced current channel for 10 minute(s).

glacial sail
visual yarrow
#

When I unmute

#

If people continue making personal attacks, I will hand out mutes.

#

!unsilence

unkempt canyonBOT
#

โœ… unsilenced current channel.

sick birch
#

thank you

final iron
#

LX can you check out this message?

slim ibex
#

this one too

final iron
#

Also while yall are here, is the slow mode going to be 6 seconds forever now?

#

Because it's super annoying

glacial sail
#

we generally keep higher slow modes in channels where people have a history of misbehaving.

#

now's not the time to ask for it to be lowered ๐Ÿ™‚

slate swan
#

i was just saying you cant compare other bots with yours

final iron
#

Okimii just drop it

visual yarrow
#

Yeah please drop the subject and move on. Thanks.

slim ibex
#

๐Ÿ‘

slate swan
#

.topic

lament depotBOT
#
**What's one feature you wish more developers had in their bots?**

Suggest more topics here!

final iron
#

Cogs

#

Also using the commands extension

#

And not using json as a database

#

And subclassing the help command

slate swan
final iron
#

Oh yeah buttons are nice

gleaming torrent
#

How do you make bots become speakers in stage channels?

final iron
#

Not sure if that's possible

#

Wait

#

Yeah I don't think its possible

#

!d disnake.StageChannel

unkempt canyonBOT
#

class disnake.StageChannel```
Represents a Discord guild stage channel.

New in version 1.7.

x == y Checks if two channels are equal.

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

hash(x) Returns the channelโ€™s hash.

str(x) Returns the channelโ€™s name.
final iron
#

You're free to look in the docs to see if I missed something

glass cypress
#

Hi guys

#

Anyone here that can assist me with something on Hikari/lightbulb? ๐Ÿ˜ฆ

final iron
#

Sure

#

I can't personally though

glass cypress
#

Well, I am new programming and I am trying to create a music bot. I found an example from a repository but it is not working for me. The bot is online bot is not joining the channel or anything, however, the ping/pong command works.

sick birch
#

Music bots... whereabouts are you getting said music from?

glass cypress
#

This is the repository, don't worry abt the token, its an old one

glass cypress
sick birch
#

Are you searching for it on youtube by URL by chance?

dry kelp
#

@sick birch

#

why if i use "else" is going to stop

sick birch
#

What do you mean?

glass cypress
#

Well, what lavalink does (for what I understood) is that it search for the song on the youtube query

sick birch
# dry kelp

Well yeah, that if/else is always going to return soemthing, so nothing below that gets executed

dry kelp
#

ah

#

so should i try this?

sick birch
#

Yes please and see if it prints

slate swan
# dry kelp ah

the return statement returns the method which the if statement will always return the method because if the condition isnt correct it will just return the method with else

slate swan
final iron
#

๐Ÿ—ฟ

sick birch
dry kelp
#

it should print on_ready right?

#

like when is ready .. print that

slate swan
#

no?

dry kelp
slate swan
#

its only gonna print if the excepting gets eaten

dry kelp
#

doesn't do that

#

exactly bruh .. the bot loads

#

loading the prefix

sick birch
#

I see, can you paste what's inside your self_prefixes.json?

slate swan
#

so on ready doesnt get triggered?

dry kelp
#

{"404264989147529217": "c"}

#

literally my id with self prefix

balmy ivy
#

how can i make it so this updates

#

so i dont gotta change it

slate swan
#

because on each prefix you check the authors id with the one stored right?

#

because if you do it will always be False as your comparing a string to an integer

final iron
balmy ivy
sick birch
dry kelp
#

@sick birch so what else?

unkempt canyonBOT
dry kelp
sick birch
slate swan
#

wouldnt work

final iron
#

I know, I'm providing an example

slate swan
#

youre comparing the objs id and not the values

dry kelp
sick birch
#

within the try:

dry kelp
#

line?

final iron
#

oh yeah

slate swan
unkempt canyonBOT
#

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

False
sick birch
#
try:
  with open(...) as f:
    self_prefixes = ...
  print(self_prefixes)
except ...:
  ...
slate swan
#

lol

sick birch
final iron
#

When should I be using is instead of ==?

slate swan
final iron
#

I know when comparing against None

dry kelp
sick birch
#

use is to check if 2 objects are pointing to the same thing i suppose you could say

final iron
#

pointing?

slate swan
final iron
#

object ids?

slate swan
#

yes

sick birch
slate swan
#

lol

final iron
#

oh

sick birch
#

!e

x = 5
y = x
print(x is y)
unkempt canyonBOT
#

@sick birch :white_check_mark: Your eval job has completed with return code 0.

True
slate swan
#

they have the same memory address

dry kelp
sick birch
#

exactly

sick birch
dry kelp
#

alr

#

didn't print shit

slate swan
dry kelp
#

mhm

#

@sick birch

sick birch
#

yikes, it's not printing it?

slate swan
# dry kelp <@!432643355634171905>

well if you want your bot to access the data faster and sqlite will be faster at it im not saying you need to change but if you really do love performance well you know what to do lol

#

BUT

dry kelp
slate swan
#

sqlite uses a file

final iron
slate swan
#

if you would like a server go for postgresql

sick birch
#

Do you have an error handler somewhere?

slate swan
final iron
#

I'm gonna time this shit myself

slate swan
sick birch
dry kelp
final iron
#

๐Ÿšช ๐Ÿƒ

slate swan
final iron
dry kelp
#
async def get_prefix(bot, message):
    author = message.author.id
    guild = message.guild.id
    try:
        with open(prefix_path, "r")as f:
            prefixes = json.load(f)
    except FileNotFoundError:
        prefixes = {}

    try:
        with open(self_prefix_path, "r")as f:
            self_prefixes = json.load(f)
            print(self_prefixes)
    except FileNotFoundError:
        print("file error")
        self_prefixes = {}

    if str(guild) not in prefixes:
        return commands.when_mentioned_or(".")(bot, message)
    elif str(guild) in prefixes:
        return commands.when_mentioned_or(*prefixes.get(str(guild)))(bot, message)
    
    if str(author) not in self_prefixes:
        return commands.when_mentioned_or(".")(bot, message)
    elif str(author) in self_prefixes:
        return commands.when_mentioned_or(*self_prefixes.get(str(author)))(bot, message)

angel = slash_util.Bot(
    command_prefix=get_prefix,
    intents=discord.Intents.all(),
    case_insensitive = True,
    help_command=None
    )
#

this is everything here

slate swan
#

im not setting up a db to time that lol

sick birch
#

I think i might know what's happening

slate swan
#

bare excepts๐Ÿ˜ 

sick birch
#

(debugging purposes only)

#

don't get mad

final iron
#

๐Ÿ˜ 

slate swan
final iron
#

^

#

๐Ÿ—ฟ

slate swan
#

so you can follow pep8pithink

dry kelp
slate swan
#

do

except Exception as e:
    raise e
dry kelp
#

@sick birch do i do that?

final iron
slate swan
#

๐Ÿ—ฟ

final iron
dry kelp
#

imma test what robin said

final iron
#

Do what okimii suggested

#

It's better

dry kelp
#

why it spam prints?

final iron
#

!e

try:
    raise ValueError
except:
    print("well I know theres an error but I have no idea what it is")
unkempt canyonBOT
#

@final iron :white_check_mark: Your eval job has completed with return code 0.

well I know theres an error but I have no idea what it is
final iron
#

!e

try:
    raise ValueError
except Exception as e:
    print("well now I know what error is it")
    raise e
unkempt canyonBOT
#

@final iron :x: Your eval job has completed with return code 1.

001 | well now I know what error is it
002 | Traceback (most recent call last):
003 |   File "<string>", line 5, in <module>
004 |   File "<string>", line 2, in <module>
005 | ValueError
dry kelp
#

@sick birch

final iron
#

See the difference?

slate swan
#

lol

dry kelp
#

ye 1 sec

slate swan
dry kelp
#

i had this before

slate swan
#

!e

a = None
print(a.strip(" "))
unkempt canyonBOT
#

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

001 | Traceback (most recent call last):
002 |   File "<string>", line 2, in <module>
003 | AttributeError: 'NoneType' object has no attribute 'strip'
dry kelp
#

idk why but whatever

#

works anyways

slate swan
#

no

#

its outside of the try and except it will always print the string

#

!indents

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

dry kelp
#

doesn't do anything now LOL

#

bro slowdown is a pain here

#

ye the print is misplaced

final iron
#

Well certain users that cause trouble are the reason there is a 6 second slowmode

#

Everyone hates it

dry kelp
#

so what's wrong with this bruh

slate swan
dry kelp
slate swan
#

in sql is so easy as this

f"SELECT prefix FROM userprefix WHERE id = {ctx.author.id};"
dry kelp
#

bro u understand that

slate swan
#

like move bro i can help you๐Ÿ˜”

dry kelp
#

that's not the issue right?

#

the issue is that the prefix is not loading

slate swan
#

nah its just sql statements lol

dry kelp
#

which doesn't makes sense cuz guild loads... + im using the same way bruh

slate swan
#

i cant really help you but if you change it will make your life easier trust me lol

#

AND its faster lol

dry kelp
#

i mean if u really want to help me with that sure

slate swan
dry kelp
#

sqlite3?

slate swan
sick birch
#

f strings

slate swan
sick birch
#

you're gonna get sql-injection'd

slate swan
#

its a async bridge

dry kelp
#

i mean ur way will be fine

slate swan
dry kelp
#

alr let's do it

slate swan
#

its not taking user input so sql injection isnt posible

sick birch
#

true true its an ID

slate swan
slate swan
dry kelp
#

i mean kinda but na

sick birch
#

SQL is kind of like it's own language i would suggest you actually learn the syntax first

final iron
slate swan
dry kelp
#

no

sick birch
#

knowing how to do CRUD operations with it is probably the most important

slate swan
#

just use placeholders

pliant gulch
#

All my homies love CRUD operations

sick birch
#

who doesn't

pliant gulch
#

All my homies hate writing LEFT JOIN statements

slate swan
slate swan
dry kelp
#

i mean if u finna tell me to learn it i will keep going with json for now tbh

#

like im currently having this pain in my ass doing this

#

let me try to do smth before

slate swan
sick birch
dry kelp
#

what if i load self prefix before guild?

visual yarrow
#

Granted, learning SQL is a whole thing.

dry kelp
#

na na i gotta test

daring olive
visual yarrow
#

Has anyone here had experience with json-based databases?

wary zenith
#

bro

visual yarrow
#

I mean, not text files.

wary zenith
#

mongo just decided not to work

sick birch
slate swan
pliant gulch
#

Mongo's queries are so bad when working with complex data

#

The queries at least with python's drivers get so bad

dry kelp
slate swan
#

sql is so simple thats why i went for it its like python simple but powerful

wary zenith
sick birch
#

I generally find writing raw queries to be distasteful

dry kelp
#

AHA! TOLD YOU! is not the json

#

is loading the prefix the pain here

slate swan
dry kelp
#

i just inverted those

visual yarrow
dry kelp
#

But that's still not alright

daring olive
#

smh age shaming

dry kelp
#

so how can i load both prefixes?

slate swan
#

and its dbs tho

sick birch
dry kelp
#

@sick birch look

#
async def get_prefix(bot, message):
    author = message.author.id
    guild = message.guild.id
    try:
        with open(prefix_path, "r")as f:
            prefixes = json.load(f)
    except FileNotFoundError:
        prefixes = {}

    try:
        with open(self_prefix_path, "r")as f:
            self_prefixes = json.load(f)
    except FileNotFoundError:
        print("file error")
        self_prefixes = {}

    if str(author) not in self_prefixes:
        return commands.when_mentioned_or(".")(bot, message)
    elif str(author) in self_prefixes:
        return commands.when_mentioned_or(*self_prefixes.get(str(author)))(bot, message)

    if str(guild) not in prefixes:
        return commands.when_mentioned_or(".")(bot, message)
    elif str(guild) in prefixes:
        return commands.when_mentioned_or(*prefixes.get(str(guild)))(bot, message)

#

this will load just the self prefix

slate swan
dry kelp
#

@sick birch u here?

pliant gulch
#

Postgres was a headache when contributing to other people's projects, when they didn't have a docker image or a schema.sql

slate swan
slate swan
dry kelp
#

@visual yarrow do u know json ?

visual yarrow
sick birch
dry kelp
#

do u know how to load 2 prefixes?

visual yarrow
#

Wdym?

dry kelp
sick birch
#

I'm getting this feeling that your self_prefixes.json is in an invalid format

slate swan
dry kelp
#

and now guild prefix is not working

slate swan
dry kelp
#

only self prefix

sick birch
#

json.loads() is very finnicky about how you need to format your json files

dry kelp
# visual yarrow Wdym?
async def get_prefix(bot, message):
    author = message.author.id
    guild = message.guild.id
    try:
        with open(prefix_path, "r")as f:
            prefixes = json.load(f)
    except FileNotFoundError:
        prefixes = {}

    try:
        with open(self_prefix_path, "r")as f:
            self_prefixes = json.load(f)
    except FileNotFoundError:
        print("file error")
        self_prefixes = {}

    if str(author) not in self_prefixes:
        return commands.when_mentioned_or(".")(bot, message)
    elif str(author) in self_prefixes:
        return commands.when_mentioned_or(*self_prefixes.get(str(author)))(bot, message)

    if str(guild) not in prefixes:
        return commands.when_mentioned_or(".")(bot, message)
    elif str(guild) in prefixes:
        return commands.when_mentioned_or(*prefixes.get(str(guild)))(bot, message)

angel = slash_util.Bot(
    command_prefix=get_prefix,
    intents=discord.Intents.all(),
    case_insensitive = True,
    help_command=None
    )
sick birch
#

You said it was like

{"id": "c"}

right?

dry kelp
#

yes

sick birch
#

Try

{
  "id": "c"
}
pliant gulch
#

*self_prefixes.get(str(author)) any specific reason why you unpack self_prefixes?

sick birch
#

I remember having some issues with that

dry kelp
#

this is how i load guild id...

#

makes no sense

#

ok so my explaining may be dumb af but like i said.. i tried reinverting those ... i put self prefix before guild prefix and now self prefix is working and guild not

dry kelp
dry kelp
#

probably stopping at line 40

sick birch
# pliant gulch ?

when_mentioned_or takes a list of arguments, probably why they're unpacking

pliant gulch
#

But if it was a string, say "foo" it would then pass "f", "o", "o"

dry kelp
#

the prefix can't be 2 characters long so ๐Ÿคทโ€โ™‚๏ธ

sick birch
#

So... a user can have multiple prefixes?

dry kelp
#

i don't do that*

#

bro 6 seconds cooldown is a pain a_sobs

sick birch
#

๐Ÿค” so each author has an entry, one user one prefix?

dry kelp
#

yep

sick birch
#

i don't know why i keep saying author

dry kelp
#

basically is the author

sick birch
#

um yeah it should be good since it's only 1 character

#

i dont think the issue is with unpacking

dry kelp
#

exactly

#

if i load guild prefix before self guild is going to work and self not

#
async def get_prefix(bot, message):
    author = message.author.id
    guild = message.guild.id
    try:
        with open(prefix_path, "r")as f:
            prefixes = json.load(f)
    except FileNotFoundError:
        prefixes = {}

    try:
        with open(self_prefix_path, "r")as f:
            self_prefixes = json.load(f)
    except FileNotFoundError:
        self_prefixes = {}

    if str(guild) not in prefixes:
        return commands.when_mentioned_or(".")(bot, message)
    elif str(guild) in prefixes:
        return commands.when_mentioned_or(*prefixes.get(str(guild)))(bot, message)

    if str(author) not in self_prefixes:
        return commands.when_mentioned_or(".")(bot, message)
    elif str(author) in self_prefixes:
        return commands.when_mentioned_or(*self_prefixes.get(str(author)))(bot, message)

angel = slash_util.Bot(
    command_prefix=get_prefix,
    intents=discord.Intents.all(),
    case_insensitive = True,
    help_command=None
    )

Now guild prefix will work

sick birch
#

and just to claer it up, self prefixes is the user prefix?

dry kelp
#

isn't there a way to make them both read?

sick birch
#

okay this is what you could do

#

get the user prefix first, if they have no user prefix, then use the guild prefix

dry kelp
#

no

#

not what i want to do sadly

#

that's smart but no..

sick birch
#

you want to do it the other way around?

dry kelp
#

i want both of them to work yk

sick birch
#

hmm

dry kelp
#

if nothing is found then . will be the one for both

sick birch
#

does get_prefix allow you to return multiple prefixes?

dry kelp
#

i seen bots doing this so pretty sure there's a way

#

i think so ... cuz i can't load 2 prefixes

sick birch
#

oh yeah

dry kelp
#

command_prefix=(get_prefix, arg2), pretty sure this won't work

sick birch
#

Okay in that case do this: make an empty list, get guild prefix, add guild prefix to list, get user prefix, add it to list if it exists, and add . as well

#

that way all 3 will work

dry kelp
#

ye idk how to do that lol

#

wym creating a list for those .. like?

sick birch
#
async def get_prefix(...):
  prefixes = []

  with open(...) as guild_prefixes:
    guild_prefix = # find guild prefix
    prefixes.append(guild_prefix)

  with open(...) as user_prefixes:
    user_prefix = # find user prefix
    prefixes.append(user_prefix)

  prefixes.append(".")

  return prefixes
pliant gulch
#

You could use collections.defaultdict, set the default to . then use .update with your JSON of guild's and users

#

Significantly reduces the size of this code down

sick birch
#

works just as well, i'm just demostrating a concept

pliant gulch
#

You can also use setdefault if you don't want to import collections

dry kelp
#
async def get_prefix(bot, message):
    author = message.author.id
    guild = message.guild.id
    prefixes = []

    with open(prefix_path, "r")as f:
        guild_prefix = prefixes[str(guild)]
        prefixes.append(guild_prefix)

    with open(self_prefix_path, "r")as f:
        self_prefix = prefixes[str(author)]
        prefixes.append(self_prefix)

    prefixes.append(".")

    return prefixes

angel = slash_util.Bot(
    command_prefix=get_prefix,
    intents=discord.Intents.all(),
    case_insensitive = True,
    help_command=None
    )
#

@sick birch

sick birch
#

use .get() instead

dry kelp
#

where

sick birch
#

and check if it's None

dry kelp
#

huh

#

instead of append?

sick birch
#
    with open(self_prefix_path, "r")as f:
        self_prefix = prefixes.get(str(author.id))
        if self_prefix:
          prefixes.append(self_prefix)
``` like so
pliant gulch
#

Your making file pointers but you aren't actually using them, unless otherwise populating prefixes somewhere else it's always empty

dry kelp
#

else??

sick birch
#

else nothing

dry kelp
#

alr

#

get() where?

sick birch
#

wait you actually have to load it first

dry kelp
#

json load?

sick birch
#
    with open(self_prefix_path, "r")as f:
        self_prefixes = json.load(f)
        self_prefix = self_prefixes.get(str(author.id))
        if self_prefix:
          prefixes.append(self_prefix)
dry kelp
#
async def get_prefix(bot, message):
    author = message.author.id
    guild = message.guild.id
    prefixes = []

    with open(prefix_path, "r")as f:
        guild_prefixes = json.load(f)
        guild_prefix = self_prefixes.get(str(guild.id))
        if guild_prefix:
          prefixes.append(guild_prefix)

    with open(self_prefix_path, "r")as f:
        self_prefixes = json.load(f)
        self_prefix = self_prefixes.get(str(author.id))
        if self_prefix:
          prefixes.append(self_prefix)

    prefixes.append(".")

    return prefixes
#

wait

#

without .id ... 1 sec

sick birch
#

You need .id

#

you're storing the user's ID in the json aren't you?

dry kelp
sick birch
#

m alright

dry kelp
#

meant here

pliant gulch
#

If you have any commands that aren't guild required your gonna get an attribute error @ message.guild.id when using commands in DMs

#

Not a problem if you have all guild only commands though

sick birch
#

just add the @commands.guild_only check

dry kelp
#

how can i load when mentioned too?

sick birch
#

or it might be @commands.guild_only() i don't remember

dry kelp
#

works ๐Ÿ‘

#

but how can i make it when mentioned too?

sick birch
#

use the when_mentioned_or

dry kelp
#

where

sick birch
#

I haven't actually used that before so i can't help with that unfortunately

dry kelp
#

but where do i use it

sick birch
#
return when_mentioned_or(*prefixes)

or something like that

pliant gulch
#

when_mentioned_or doesn't return a list though

#

It returns another function

tall venture
sick birch
pliant gulch
#

You'd just do when_mentioned_or(*prefixes)(Bot, Message)

#

Except here this is just super in-efficient as you unpack for when_mentioned_or, then the inner function of it turns it back into a list

#

the optimal and the way I would suggest is just appending "<@bot_id>" to the list

#

Or <@!bot_id>

sick birch
#

bot.user.mention?

pliant gulch
#

Yes this also works, does the same thing as what I said

sick birch
#

@dry kelp in that case try this:

async def get_prefix(bot, message):
    author = message.author.id
    guild = message.guild.id
    prefixes = [".", bot.user.mention]
    # other stuff here
    return prefixes
dry kelp
#

it works

#

dw is fine

#

or should i?

#

what's the difference ?

#

@sick birch

sick birch
#

not much

dry kelp
#

then is fine like this tbh

sick birch
#

same as this

async def get_prefix(bot, message):
    author = message.author.id
    guild = message.guild.id
    prefixes = []
    prefixes.append(".")
    prefixes.append(bot.user.mention)
    # other stuff here
    return prefixes
dry kelp
#

no but like

#

what if i use when mentioned or

#

what's the difference between that?

pliant gulch
#

The difference is the speed it takes

#

You unpack, then the function turns it back into a list

dry kelp
#

oh

pliant gulch
#

super in-efficient when you don't need to do that

sick birch
#

I'm gonna go on a limb here and say it doesn't matter since they're using JSON

dry kelp
#

wait

sick birch
#

if you're doing when_mentioned_or you can get rid of thet bot.user.mention part

dry kelp
#

return just prefixes

sick birch
#

yes, just return prefixes

dry kelp
#
async def get_prefix(bot, message):
    author = message.author.id
    guild = message.guild.id
    prefixes = [".", bot.user.mention]

    with open(prefix_path, "r")as f:
        guild_prefixes = json.load(f)
        guild_prefix = guild_prefixes.get(str(guild))
        if guild_prefix:
            prefixes.append(guild_prefix)

    with open(self_prefix_path, "r")as f:
        self_prefixes = json.load(f)
        self_prefix = self_prefixes.get(str(author))
        if self_prefix:
            prefixes.append(self_prefix)

    return prefixes
sick birch
#

there you are

final iron
#

Just wanted to ask, you claim you have the fastest anti-nuke bot but you use json and inefficient methods?

sick birch
#

I would assume fastest as in network speed

dry kelp
#

@sick birch

#

doesn't really work this way

sick birch
#

what's wrong with it?

pliant gulch
dry kelp
#

the command doesn't work when i ping the bot

sick birch
#

Are you returning just prefixes?

dry kelp
#

mhm

sick birch
#

hmm

#

well i suppose just use when_mentioned_or then

slate swan
dry kelp
#
async def get_prefix(bot, message):
    author = message.author.id
    guild = message.guild.id
    prefixes = [".", bot.user.mention]

    with open(prefix_path, "r")as f:
        guild_prefixes = json.load(f)
        guild_prefix = guild_prefixes.get(str(guild))
        if guild_prefix:
            prefixes.append(guild_prefix)

    with open(self_prefix_path, "r")as f:
        self_prefixes = json.load(f)
        self_prefix = self_prefixes.get(str(author))
        if self_prefix:
            prefixes.append(self_prefix)

    return commands.when_mentioned_or(*prefixes)(bot, message)
dry kelp
#

this is just in 36 serverrs

#

servers

slate swan
#

so you made it left servers for test reasons or?

dry kelp
#

no why would i make it leave?

#

i just changed the token

slate swan
#

does it really remove your verified badge?

dry kelp
#

i never had the verify badge

slate swan
dry kelp
#

my 1st bot was in 113

#

i just said "fuck discord taking to long"

slate swan
#

wasnt that the same bot spooky?

dry kelp
#

they replied after 6 months

#

it probably was in 76 i just made it leave some servers

#

less than 100 members

slate swan
#

๐Ÿ—ฟ

sick birch
slate swan
dry kelp
slate swan
#

seems weird

#

why would the team that approve discord bots take so longpithink

dry kelp
#

idk now verification take like

#

3 months

slate swan
#

i doubt thatpithink

dry kelp
#

u can check discord developer server

#

if ur in they're server just click on this

slate swan
#

im not in the server lol

dry kelp
#

do i invite u?

slate swan
#

sure

dry kelp
#

also if u don't believe me i think that i still got the tickets in my yahoo mail inbox lol

#

@slate swan check the time

final iron
#

tbh who uses yahoo

dry kelp
#

i got gmail too

#

is just that this discord acc has yahoo linked

slate swan
dry kelp
#

never planned to change

slate swan
#

im not even sure if it removes the badge

dry kelp
#

i tough that they will never reply ๐Ÿ˜‚

#

so i just said "imma make a new revamped bot"

slate swan
#

:/

dry kelp
#

im glad i did

#

is way better

#

@hushed field tested it .. i mean the antinuke

#

u can test it too if u want lol

slate swan
dry kelp
final iron
#

How do you test the bot anyway

slate swan
slate swan
dry kelp
#

antinuke logs

#

i will add normal logs too

slate swan
# dry kelp yep

you should show them to show why your bot is better so everybody knows your bot is fast ig lol

dry kelp
#

im just working on them

slate swan
#

no no

#

i mean like logs on like timing

dry kelp
#

wym

sick birch
slate swan
# dry kelp wym

well how much time it took to change what had been done to the channel etc

sick birch
#

Sharding just does not work with json at all

dry kelp
#

because if a channel is being deleted

slate swan
dry kelp
#

the bot will ban the target then restore everything

sick birch
#

50 is pushing it

slate swan
dry kelp
#

i saw nukers that could ban 50+ a sec

#

if a nuker like this comes my bot reacts after 49

slate swan
#

ive seen a botnet of 100+ the person was using proxies iirc

dry kelp
#

so is probably a 0.9 reaction time

#

nobody can get 100 trust me

sick birch
final iron
#

@dry kelp How do you test your bots speed?

slate swan
#

just saying what youre doing is wrong

dry kelp
#

and mine replied faster

slate swan
#

breaking tos to stop nukers is like fighting fire with fire

sick birch
dry kelp
#

my bot replies faster than wick.. or summrs.. or any other bots lol

final iron
#

Like test how fast the anti nuke is

cerulean osprey
#

How would I go about getting an emoji id (if I have to for standard emojis)

dry kelp
#

so i could

slate swan
dry kelp
#

im using digital ocean .. the 15$ droplet

sick birch
cerulean osprey
final iron
sick birch
final iron
sick birch
#

wait

cerulean osprey
dry kelp
#

bro what

cerulean osprey
#

Except those are the same thing xD

final iron
#

How are you testing your reaction time

#

You keep throwing out numbers

dry kelp
#

my delete channel anti is faster than the create one for a reason

slate swan
sick birch
#

Very miniscule yes

#

But network overheads and network transmissions times will usually overshadow that

slate swan
#

your bot is so fast its gonna get ratelimited so easily on a real nuke lol

sick birch
#

Different story with more time consuming algorithms

dry kelp
#

there's something dumb that all the antinuke bots don't do ... if a nuker spam 50 channels per sec the antinuke bots will delete just about 20!
My bot will async with the audit log for that person and then delete all the channels ... so the reaction of the ban is fast.. is just that it will take 1-2 seconds to delete the channels

#

depends of the ratelimit + how many channels

slate swan
#

tries to ban a 50+botnet and boom gets ratelimited and the server goes bye bye

sick birch
#

Yeah discord ratelimits are the biggest bottleneck

final iron
dry kelp
#

@sick birch i was able to make the anti vanity

slate swan
#

AND BTW

#

your bot is useless on a nuke lol

sick birch
#

If you frequently hit rate limits that can get discord's attention (don't quote me on it though)

final iron
#

tbh your bot can easily be bypassed

slate swan
#

when allot of request happen in a guild discord ratelimits the guild thats why some people cant ban the nukers or change perms and thats why they use bots so your bot is so quick i doubt it wouldnt get ratelimited lol

supple thorn
final iron
#

I haven't ever nuked a server and even I know a simple way to bypass your bot

dry kelp
slate swan
#

most antinukes are a bit slow as they dont want to get ratelimited lol

dry kelp
#

i assure u that u can't

final iron
dry kelp
#

How can i use commands group in main file? (not cog)

@commands.group(invoke_without_command=True, case_insensitive=True, aliases=["sp"])
@commands.check_any(commands.is_owner(), is_guild_owner())
async def setprefix(ctx, prefix):
final iron
#

I'm not saying I'll test it

dry kelp
final iron
#

I'm just presenting a major security hole

dry kelp
#

so ur bot will get stopped instantly.. n then replace what happened

woven ingot
#

Would really appreciate some help
I'm pulling an API but its not working I belive its because of how I'm calling the data. Had another API before and it worked perfectly

@tasks.loop(seconds=20)
async def loop():
    token = open('crypto.txt', 'r').read()
    url = f"https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&ids=near"

    data = requests.get(url).json()['id']['current_price']```
 
These are the logs

2022-02-28T01:48:27.194351+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.9/site-packages/discord/ext/tasks/init.py", line 101, in _loop
2022-02-28T01:48:27.194352+00:00 app[worker.1]: await self.coro(*args, **kwargs)
2022-02-28T01:48:27.194360+00:00 app[worker.1]: File "/app/main.py", line 21, in loop
2022-02-28T01:48:27.194360+00:00 app[worker.1]: data = requests.get(url).json()['id']['current_price']
2022-02-28T01:48:27.194385+00:00 app[worker.1]: TypeError: list indices must be integers or slices, not str
So yeah I belive I'm calling the data incorrectly in line 21
data = requests.get(url).json()['id']['current_price']```

final iron
#

And if someone nukes in 2 waves?

slate swan
#

a botnet would ratelimit your bot trust me on that

dry kelp
#

i tested with 3 nukers at once lol

slate swan
final iron
#

If someone nukes in 2 waves your bot would get crippled

dry kelp
#

non trusted users can't add bots

slate swan
#

we are talking about real nukes

dry kelp
#

bro i tested everything

final iron
#

1st wave to get your bot rate limited, 2nd wave to destroy the server

dry kelp
#

im talking about real nukers too ๐Ÿ˜‚

slate swan
dry kelp
#

omfg im just getting turned on rn

slate swan
#

people dont nuke with bots lol

dry kelp
#

even if the bot gets ratelimited

#

it asyncs with the audit log

final iron
dry kelp
#

replace everything within the ratelimit

final iron
#

Also requests is blocking

dry kelp
cold sonnet
woven ingot
# final iron Can we see how the json data is formatted?

Json Data
[{"id":"near","symbol":"near","name":"Near","image":"https://assets.coingecko.com/coins/images/10365/large/near_icon.png?1601359077","current_price":8.52,"market_cap":5472313322,"market_cap_rank":27,"fully_diluted_valuation":8522099113,"total_volume":225783335,"high_24h":9.24,"low_24h":8.38,"price_change_24h":-0.692059827291,"price_change_percentage_24h":-7.50884,"market_cap_change_24h":-432887084.9098625,"market_cap_change_percentage_24h":-7.33061,"circulating_supply":642132090.936281,"total_supply":1000000000.0,"max_supply":1000000000.0,"ath":20.44,"ath_change_percentage":-58.44599,"ath_date":"2022-01-16T22:09:45.873Z","atl":0.526762,"atl_change_percentage":1512.27509,"atl_date":"2020-11-04T16:09:15.137Z","roi":null,"last_updated":"2022-02-27T22:33:21.362Z"}]

supple thorn
cerulean osprey
#

Wait, if I were to just do emoji.name could I just use :arrow_backward: for โ—€๏ธ ?

slate swan
# dry kelp they do

yes they do but thast just a low level nuke which is barely called a nuke lol

dry kelp
sick birch
dry kelp
#

can someone tell me how to use commands group in main files?

#

lol

final iron
slate swan
dry kelp
#

BRO HOW CAN I USE COMMANDS GROUPS IN MAIN FILE? ๐Ÿ˜ญ

sick birch
#

Refer to RFC 6585 for more info on rate limits

slate swan
#

@dry kelp btw i suppose youre using the raw endpoints rightpithink

dry kelp
#

bro can someone ask my question

#

i just don't want to continue the conversation since i received a warning from the bot

woven ingot
# woven ingot Json Data ``` [{"id":"near","symbol":"near","name":"Near","image":"https://asset...

You sure I have pulled info from another api and it worked.

@tasks.loop(seconds=20)
async def loop():
    token = open('crypto.txt', 'r').read()
    url = f"https://api-v2-mainnet.paras.id/collection-stats?collection_id={token}"
    
    global totalminted
    totalminted = requests.get(url).json()["data"]["results"]["total_cards"]
    floorprice = requests.get(url).json()["data"]["results"]["floor_price"] ```

This one works and didnt index.
dry kelp
#

i got anger issues .. and this cooldown just triggers me

slate swan
#

lol

dry kelp
#

na fr

#

how can i use commands group in main file? ๐Ÿ˜ญ

final iron
#

Can I see the json data for the 2nd api?

dry kelp
woven ingot
dry kelp
#

THIS IS NOT WORKING PLS HELP a_sobs

final iron
#

That's why you don't have to index it

torn sail
dry kelp
#

huh?

woven ingot
#

Or some documentation I can read

final iron
unkempt canyonBOT
#

@final iron :white_check_mark: Your eval job has completed with return code 0.

this
final iron
#

This is indexing

woven ingot
#

So something like this?

final iron
#

That is getting the 3rd

woven ingot
final iron
#

No

#

@slate swan Can you help?

#

I have to do homework

whole isle
#

how do you set the status to watching instead of playing?

slate swan
cerulean osprey
whole isle
#

thanks

woven ingot
#

No worries you guys if you have some time later or some other day would appreciate it @slate swan and @final iron

final iron
#

Try this

#

Also don't use requests, it's blocking. Use aiohttp instead

#

!blocking

unkempt canyonBOT
#

Why do we need asynchronous programming?
Imagine that you're coding a Discord bot and every time somebody uses a command, you need to get some information from a database. But there's a catch: the database servers are acting up today and take a whole 10 seconds to respond. If you do not use asynchronous methods, your whole bot will stop running until it gets a response from the database. How do you fix this? Asynchronous programming.

What is asynchronous programming?
An asynchronous program utilises the async and await keywords. An asynchronous program pauses what it's doing and does something else whilst it waits for some third-party service to complete whatever it's supposed to do. Any code within an async context manager or function marked with the await keyword indicates to Python, that whilst this operation is being completed, it can do something else. For example:

import discord

# Bunch of bot code

async def ping(ctx):
    await ctx.send("Pong!")

What does the term "blocking" mean?
A blocking operation is wherever you do something without awaiting it. This tells Python that this step must be completed before it can do anything else. Common examples of blocking operations, as simple as they may seem, include: outputting text, adding two numbers and appending an item onto a list. Most common Python libraries have an asynchronous version available to use in asynchronous contexts.

async libraries
The standard async library - asyncio
Asynchronous web requests - aiohttp
Talking to PostgreSQL asynchronously - asyncpg
MongoDB interactions asynchronously - motor
Check out this list for even more!

frozen patio
#

ok, a problem I have

slim ibex
#

if its in a class, it needs self as its first parameter if it isnt a class or static method

frozen patio
#

it says that there is a problem with my button I am trying to make

cerulean osprey
#

<discord.embeds.Embed object at 0x7f0a41c55e50>
Im setting up an embed with multiple pages, except I just get this. I've seen this happen before but I forget how to fix it, this is the code:

      p1 = embedstorm
      p2 = embedstar
      p3 = embedspring
      p4 = embedwind
      p5 = embeddragon
      p6 = embeddawn
      p7 = embedstorm1
      p8 = embedstorm2

      pages = [p1 , p2 , p3 , p4 , p5 , p6 , p7 , p8]
      
      await message.channel.send(p1)
      async def on_reaction_add(emoji, user):
        page = 0
        left = "โ—€๏ธ"
        right = "โ–ถ๏ธ"
        while True:
            msg = await message.channel.send(embed=pages[(page)])
        
        l = page != 0
        r = page != len(pages) - 1
        if l:
            await msg.add_reaction(left)

        if r:
            await msg.add_reaction(right)
          
        react = await client.wait_for('reaction_add', check=predicate(msg, l, r))
        
        if react[0] == left:
            page -= 1
        elif react[0] == right:
            page += 1
woven ingot
#

2022-02-28T02:43:09.678939+00:00 app[worker.1]: File "/app/main.py", line 21, in loop
2022-02-28T02:43:09.678939+00:00 app[worker.1]: floorprice = requests.get(url).json()[0]["data"]["results"]["floor_price"]
2022-02-28T02:43:09.678963+00:00 app[worker.1]: KeyError: 'data'

final iron
#

Can you send how the json data is formatted again?

slate swan
slate swan
unkempt canyonBOT
#

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

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | KeyError: 'anotherkey'
slate swan
#

happens when such a key isnt found

frozen patio
#

i removed the follow up

slate swan
woven ingot
# final iron Can you send how the json data is formatted again?

[{"id":"near","symbol":"near","name":"Near","image":"https://assets.coingecko.com/coins/images/10365/large/near_icon.png?1601359077","current_price":8.52,"market_cap":5472313322,"market_cap_rank":27,"fully_diluted_valuation":8522099113,"total_volume":225783335,"high_24h":9.24,"low_24h":8.38,"price_change_24h":-0.692059827291,"price_change_percentage_24h":-7.50884,"market_cap_change_24h":-432887084.9098625,"market_cap_change_percentage_24h":-7.33061,"circulating_supply":642132090.936281,"total_supply":1000000000.0,"max_supply":1000000000.0,"ath":20.44,"ath_change_percentage":-58.44599,"ath_date":"2022-01-16T22:09:45.873Z","atl":0.526762,"atl_change_percentage":1512.27509,"atl_date":"2020-11-04T16:09:15.137Z","roi":null,"last_updated":"2022-02-27T22:33:21.362Z"}]

#

Should i change data to id?

slate swan
slate swan
slate swan
slate swan
slate swan
#

your eyes are creepy awkward1

slate swan
#

kek

woven ingot
slate swan
woven ingot
slate swan
#

imagine sorting them peepocry

import json

response = api_response
with open("./data.json", "w") as f:
  json.dump(response, f, sort_keys=True, indent=4)
#

๐Ÿ—ฟ

slate swan
#

which return?

#

what are you returning python๐Ÿ˜‚

slate swan
cerulean osprey
#

If I did message.channel.send() how could I add a reaction to the sent message?

jade garden
slate swan
unkempt canyonBOT
#

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

Add a reaction to the message.

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

You must have the [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission to use this. If nobody else has reacted to the message using this emoji, the [`add_reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.add_reactions "discord.Permissions.add_reactions") permission is required.
cerulean osprey
slate swan
slate swan
jade garden
#

What is audit action for
Anti member update

slate swan
slate swan
slate swan
#

๐Ÿ˜ 

slate swan
slate swan
jade garden
slate swan
#

.....what

slate swan
jade garden
#

Audit log action? Cmd

slate swan
#

sorry i dont quite understand what you're referring to?

jade garden
#

@unkempt canyon via this bot

slate swan
#

!d discord.Guild.audit_logs

unkempt canyonBOT
#

async for ... in audit_logs(*, limit=100, before=None, after=None, oldest_first=None, user=None, action=None)```
Returns an [`AsyncIterator`](https://discordpy.readthedocs.io/en/master/api.html#discord.AsyncIterator "discord.AsyncIterator") that enables receiving the guildโ€™s audit logs.

You must have the [`view_audit_log`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.view_audit_log "discord.Permissions.view_audit_log") permission to use this.

Examples

Getting the first 100 entries:

```py
async for entry in guild.audit_logs(limit=100):
    print(f'{entry.user} did {entry.action} to {entry.target}')
```...
slate swan
jade garden
#

Is there a way to Music bot in py?

sick birch
#

Depends on where you get your music from

#

Playing youtube videos using discord bot is against their terms of service

sick birch
#

You'd have to read their TOS

jade garden
#

But many bots play music from youtube

sick birch
jade garden
sick birch
#

Rhythm was shut down was it not?

#

So was Groovy

jade garden
sick birch
#

Yes but in accordance with rule 5 i'm not allowed to talk or provide assistance with it

final iron
#

MEE6 is still streaming music so they're about to bonked

jade garden
#

I am just asking

#

Not taking your help to make my bot

#

Just normal asking

final iron
#

It is possible

#

That's the most we can say

jade garden
final iron
#

We cannot tell you how to do it

#

That would break rule 5

#

!rule 5

unkempt canyonBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.

jade garden
#

Bruh

boreal ravine
slate swan
sick birch
#

there is but it's against their TOS so we can't say what it is

#

"access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as expressly authorized by the Service; or (b) with prior written permission from YouTube and, if applicable, the respective rights holders;"

boreal ravine
#

of course there's a way

#

but rule 5

slate swan
muted valve
#

I want to make my bot respond to pings how would i do that? Im useing discord .py

slate swan
unkempt canyonBOT
#

discord.ext.commands.when_mentioned(bot, msg)```
A callable that implements a command prefix equivalent to being mentioned.

These are meant to be passed into the [`Bot.command_prefix`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.command_prefix "discord.ext.commands.Bot.command_prefix") attribute.
muted valve
#

Thank you

slate swan
#

yw

muted valve
#

So i would do @bot.event
Discord.ext.commands.when_mentioned(message)?

slate swan
#

nah its like a prefix

muted valve
#

Ohhhh

slate swan
#

you add it to the command_prefix kwarg

#

isnt when_mentioned_or a better option then

muted valve
#

Okay

slate swan
muted valve
#

How would o give it multiple sayings?

slate swan
#

pardon?

muted valve
#

Like uh multiple options like option a and option b so its randomized between the 2

slate swan
#

they want to use it in an on_message, okimii

slate swan
#

yes

slate swan
#

what wtf

muted valve
#

I want to have kt speak on ping so if someome pings it theres a list of things it could say

slate swan
muted valve
#

Huh?

#

Sorry im very limited with my understanding of discord .py

slate swan
muted valve
#

Uh no

slate swan
muted valve
#

When someoke pings it it van say like
Hello
Or why ping

slate swan
muted valve
#

Kinda like slug bot does

slate swan
#

!e

import random
print(random.choice([True, False]))
unkempt canyonBOT
#

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

True
slate swan
#

!e

import random
print(random.choice([True, False]))
unkempt canyonBOT
#

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

False
slate swan
#

or if you want a one liner๐Ÿ˜ณ

#

!e

print(__import__("random").choice([True,False]))
unkempt canyonBOT
#

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

True
slate swan
#

๐Ÿ˜ณ

muted valve
#

Uh okay
.
.

#

!close

#

I forgot how it works

slate swan
muted valve
#

Kh wait this isnt a help chan

#

Km dumb sorry

slate swan
#

its ok

muted valve
#

Its also late where i libe so my brain is kinda sleepy

slate swan
#

happens๐Ÿ˜…

vast gale
#

aaaaaaaaaa

slate swan
slate swan
slate swan
#

just check who added the reaction otherwise clear the reaction if not admin

modest plover
#
import disnake
from disnake.ext import commands, tasks
import random

botstatus = [
	"with my files",
	"on a Wii U",
	"on a Nintendo DS",
	"Mario Party DS",
	"Rocket League",
	"Apex Legends",
	"Spiderman PS4",
	"with my maker"]

class Status(commands.Cog):
	"""Changes the status automatically every 30 minutes."""
	
	def __init__(self, bot = commands.Bot):
		self.bot = bot
		self.change_status.start(bot)
	
	@tasks.loop(minutes=10.0)
	async def change_status(self, bot):
		playing = random.choice(botstatus)
		await self.bot.change_presence(activity=disnake.Game(name=playing))
		
	def cog_unload(self):
		self.change_status.stop()

def setup(bot):
	bot.add_cog(Status(bot))
	print(" | Loaded Extension: Status")
Unhandled exception in internal background task 'change_status'.
Traceback (most recent call last):
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/disnake/ext/tasks/__init__.py", line 157, in _loop
    await self.coro(*args, **kwargs)
  File "/storage/emulated/0/Coding/discord-bots-repo/Ultimatium/commands/status.py", line 25, in change_status
    await bot.change_presence(activity=disnake.Game(name=playing))
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/disnake/client.py", line 1434, in change_presence
    await self.ws.change_presence(activity=activity, status=status_str)
AttributeError: 'NoneType' object has no attribute 'change_presence'

I keep getting this error.

slate swan
#

self.bot.change_presence

modest plover
#

That doesn't fix it

slate swan
#

huh

slim ibex
#

bot isn't supposed to equal commands.Bot

modest plover
# slate swan huh
Unhandled exception in internal background task 'change_status'.
Traceback (most recent call last):
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/disnake/ext/tasks/__init__.py", line 157, in _loop
    await self.coro(*args, **kwargs)
  File "/storage/emulated/0/Coding/discord-bots-repo/Ultimatium/commands/status.py", line 25, in change_status
    await self.bot.change_presence(activity=disnake.Game(name=playing))
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/disnake/client.py", line 1434, in change_presence
    await self.ws.change_presence(activity=activity, status=status_str)
AttributeError: 'NoneType' object has no attribute 'change_presence'

It doesn't fix it.

slim ibex
#

commands.Bot is supposed to be the typehint

slate swan
slim ibex
#

bot: commands.Bot

slate swan
#

you're setting the default value of bot es_pepe_cry

slim ibex
#

๐Ÿ—ฟ

modest plover
#

oh

slate swan
modest plover
#

changed it now, still doesn't work

slim ibex
#

well ws is None

#

oh wait

#

thats disnake code

modest plover
#

Correct

slim ibex
#

i read the traceback lol

slate swan
slim ibex
#

waut nvm

slate swan
#

....

slim ibex
#

this isn't a fucking subclass ๐Ÿ’€

#

im so tired rn i shouldn't be helping

#

you should probably just set the status in an on_ready listener. but, regardless, you don't need to pass bot to your function there. doesn't seem like its being used

slate swan
slim ibex
#

i do thatpydis_peek

slate swan
slim ibex
#

k

#

well it won't matter anymore because i am no longer making discord bots ๐Ÿ—ฟ

slate swan
slim ibex
#

ye bot dev is so boring

slate swan
#

now

slim ibex
#

well anyways @modest plover, seems like self.bot is None

#

where do you create your bot instance/subclass

modest plover
#

Wdum?

#

Sorry it's like 5am and half the shit you're saying looks like a blur to me

slim ibex
#

lol

green veldt
#

vc = ctx.me.voice_client
AttributeError: 'Member' object has no attribute 'voice_client'

slim ibex
modest plover
#
import disnake
from disnake.ext import commands
import os
from dotenv import load_dotenv
import platform

load_dotenv()

token = os.environ["token"]
split = ("----------------------")
indent = " | "
bot = commands.Bot()
def loading():
	print(f"Bot stats:")
	print(f"{indent}Name: {bot.user}")
	print(f"{indent}ID: {bot.user.id}")
	print(f"{indent}Latency: {round(bot.latency * 1000)}ms")
	print(f"{indent}Disnake Version: {disnake.__version__}")
	print(f"{indent}Python Version: {platform.python_version()}")

bot.load_extensions("commands")

@bot.event
async def on_ready():
	loading()
bot.run(token)
modest plover
modest plover
green veldt
#
AttributeError: 'Member' object has no attribute 'voice_client'```
slate swan
unkempt canyonBOT
#

property voice_client: Optional[VoiceProtocol]```
A shortcut to [`Guild.voice_client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.voice_client "discord.Guild.voice_client"), if applicable.
slate swan
#

ctx.voice_client

green veldt
#

ok thanks

slate swan
green veldt
#

i think i had that before

#

lemme try

slate swan
green veldt
#

what would be the difference

slate swan
green veldt
#

ok thx

slate swan
#

!d discord.Guild.voice_client

unkempt canyonBOT
#

property voice_client: Optional[VoiceProtocol]```
Returns the [`VoiceProtocol`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceProtocol "discord.VoiceProtocol") associated with this guild, if any.
slate swan
#

same thing thisisfine

green veldt
#

ohk

#

@slate swan

slate swan
#

hm?

green veldt
#

its giving access denied and a loooonnngggg link when i play

#

im using youtube video

slate swan
#

permission*

green veldt
#

it has admin perms

slate swan
green veldt
#

HTTP error 403 Forbidden

slate swan
#

403 raises when you dont have permissions

green veldt
#

um

#

but the bot has admin perms??

slate swan
#

s.m.h.

#

says it all lol

green veldt
#

im getting this when i click the link

slate swan
#

!rule 5

unkempt canyonBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.

green veldt
slate swan
#

ytdl breaks youtube's TOS

green veldt
#

how

slate swan
#

!ytdl

unkempt canyonBOT
#

Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.

For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:

The following restrictions apply to your use of the Service. You are not allowed to:

1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service;  (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;

3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTubeโ€™s robots.txt file; (b) with YouTubeโ€™s prior written permission; or (c) as permitted by applicable law;

9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
green veldt
#

um

#

i saw a youtube video

slate swan
green veldt
#

to make this bot

#

he just did that

sick birch
#

Probably becuase the youtube video is heavily outdated like 90% of all of them related on discord bots

green veldt
slate swan
green veldt
#

its back

sick birch
#

No, it's not

green veldt
#

๐Ÿ˜‚

slate swan
#

s.m.h. whats to laugh

sick birch
#

Using youtube to stream music to your bots is against their terms of service. Period.

green veldt
#

what to do now

#

should i then use spotify

sick birch
#

Not much really, other than scrap the idea of a music bot

slate swan
sick birch
green veldt
#

okay

#

thanks!

slate swan
green veldt
#

um

#

so from where can i play music

slate swan
sick birch
#

Most audio streaming platforms don't want you to

green veldt
#

how do the music bots work then

sick birch
#

They don't

green veldt
#

some do

slate swan
#

the remaining ones are gonna be shot down soon

sick birch
#

Won't for much longer depending on their source

#

Youtube and discord are cracking down on it heavily

green veldt
#

ok.....

#

thanks for the help

#

im gonna delete that then

sick birch
#

Sorry we couldn't do more but rules are rules you know

green veldt
#

yup

slate swan
#

@green veldt awkward1

modest plover
green veldt
#

my friend did im gonna remove that

slate swan
#

lmao

green veldt
#

i definitely know

sick birch
green veldt
sick birch
#

You're not going to prison for using a self bot, it's just against terms of service

modest plover
#
Unhandled exception in internal background task 'change_status'.
Traceback (most recent call last):
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/disnake/ext/tasks/__init__.py", line 157, in _loop
    await self.coro(*args, **kwargs)
  File "/storage/emulated/0/Coding/discord-bots-repo/Ultimatium/commands/status.py", line 25, in change_status
    await self.bot.change_presence(activity=disnake.Game(name=playing))
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/disnake/client.py", line 1434, in change_presence
    await self.ws.change_presence(activity=activity, status=status_str)
AttributeError: 'NoneType' object has no attribute 'change_presence'

I'm still confused by this

sick birch
#

Looks like it's in a cog

green veldt
modest plover
#
import disnake
from disnake.ext import commands, tasks
import random

botstatus = [
	"with my files",
	"on a Wii U",
	"on a Nintendo DS",
	"Mario Party DS",
	"Rocket League",
	"Apex Legends",
	"Spiderman PS4",
	"with my maker"]

class Status(commands.Cog):
	"""Changes the status automatically every 10 minutes."""
	
	def __init__(self, bot: commands.Bot):
		self.bot = bot
		self.change_status.start(bot)
	
	@tasks.loop(minutes=10.0)
	async def change_status(self, bot):
		playing = random.choice(botstatus)
		await self.bot.change_presence(activity=disnake.Game(name=playing))
		
	def cog_unload(self):
		self.change_status.stop()

def setup(bot):
	bot.add_cog(Status(bot))
	print(" | Loaded Extension: Status")

It is

modest plover
# green veldt how

Idk I just know it's doable, I used Hydra to play my soundclown shitpost playlist to my friend

zenith basin
#
    
@commands.Cog.listener()
    async def on_raw_reaction_remove(self, payload: discord.RawReactionActionEvent):
        guild = self.bot.get_guild(payload.guild_id)
        if guild is None:
            return
        member = guild.get_member(payload.user_id)
        if member is None:
            return
        # if they remove the reaction remove the rol

        print(member)
        message = await guild.get_channel(payload.channel_id).fetch_message(payload.message_id)

        if payload.guild_id == 915076185740939304:
            #get reaction roles
            reaction_roles_data = self.reaction_roles_data[payload.guild_id]
            #get the role
            for reaction_role in reaction_roles_data:
                if reaction_role["emoji"] == payload.emoji.name:
                    role = discord.utils.get(member.role, id=reaction_role["roleID"])
                    await member.remove_roles(role)
                    break
green veldt
zenith basin
#
Ignoring exception in on_raw_reaction_remove
Traceback (most recent call last):
  File "C:\Users\\Trello\venv\lib\site-packages\discord\client.py", line 382, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\\Trello\cogs\Reaction.py", line 110, in on_raw_reaction_remove
    role = discord.utils.get(member.role, id=reaction_role["roleID"])
AttributeError: 'NoneType' object has no attribute 'role'
#

saying member is None

slate swan
#

hey i want to access errors in that error
anyone know how to do that?

modest plover
#

SoundCloud is allowed

green veldt
modest plover
#
Streaming Tracks
Note if you are going to stream from our API you need to attribute properly. Make sure you've read our Terms and Attribution Guidelines to make sure you treat our creators content correctly. When using a custom player you must:

Credit the uploader as the creator of the track
Credit SoundCloud as the source by including one of the logos found here
Link to the SoundCloud URL containing the work
If the track is private link to the profile of the creator
If you don't want to use the SoundCloud widget, our API gives you the ability to access a track's stream URL and use your own player to play tracks from SoundCloud. In order to get a URL for streaming, you can request the appropriate resource and make note of the stream_url property. Send a GET request to that URL and you will get a set of links with available transcodings which you can choose from.
green veldt
#

btw my bot just left my server itself๐Ÿ˜ฑ๐Ÿ˜ฑ

modest plover
#

It says you can use your own player to play tracks from SoundCloud

green veldt
sick birch
#

That's odd since d.py should provide bot for you

slate swan
green veldt
alpine furnace
slate swan
slate swan
green veldt
#

HOW DID MY BOT LEFT MY TEST SERVER ITSELF!!!

slate swan
#

๐Ÿ˜ณ

green veldt
#

BRUH

#

not a joke

slate swan
#

okk

sick birch
#

Unless your code is malfunctioning someone has your token and you should regen it immediately

green veldt
#

ok

#

done

slate swan
#

if everything is right there

green veldt
#

check what there