#discord-bots

1 messages · Page 693 of 1

slate swan
#

What does the loop kwarg take?

#

Ints?

upbeat otter
slate swan
upbeat otter
slate swan
#

Are you blind?

slate swan
#

I need command ideas

upbeat otter
maiden fable
slate swan
upbeat otter
#

coughs

slate swan
#

I didnt mean to offend her it was a jk

maiden fable
slate swan
unkempt canyonBOT
slate swan
#

Keep on topic mr

upbeat otter
#

Lollll

slate swan
#

Or else

maiden fable
#

Hm? Or else?

slate swan
maiden fable
#

Do u really think that I care about u being anywhere in the world?

upbeat otter
unkempt canyonBOT
slate swan
upbeat otter
#

Welcome

slate swan
#

🕴️

slate swan
#

A marriage bot wtf

upbeat otter
manic wing
#

i thought christians were supposed to have love in their heart

upbeat otter
#

Tinder bot or smth like that?

#

Lol

slate swan
#

grab a message, use some shitty translator api to change it and reply to it on that lang

upbeat otter
#

That dont work

#

To be specific

slate swan
#

Ayo?

dire folio
#

You should make a bot that is very infuriating

slate swan
pliant gulch
#

Lol tinder bot

upbeat otter
pliant gulch
#

Reminds me of the bot kai was making, was actually tinder bot

slate swan
#

Guys i said COMMAND ideas

mighty dust
#
async def send_dm(ctx, member: discord.Member, *, content):
    channel = await member.create_dm()
    await channel.send(content) 

what will the command look like when the user will send a message?

dire folio
#

Oh command

dire folio
slate swan
#

Andy you remind me each day that i should start my wrapper

#

And i hate it

pliant gulch
#

Just do it lol

slate swan
#

You better not take my idea

pliant gulch
#

I'll take it if you don't do it

slate swan
slate swan
mighty dust
slate swan
#

dankmemer v2 cuz dankmemer removed nsfw

#

literally with the name dank memer

dire folio
slate swan
upbeat otter
slate swan
#

no just make it

slate swan
slate swan
dire folio
upbeat otter
# slate swan Whats that?

Random people in random servers use --userphone and can talk with each other connected to different nodes

slate swan
#

Haha no.

#

Need a good one

#

make backup / template bot

#

A multidollar one

upbeat otter
slate swan
#

What is going on inside your head🕴️

dire folio
#

Well u may get multiple dollars

slate swan
#

Bro?

#

You guys really want me to break tos

dire folio
#

no

slate swan
#

First you guys want me to make a nuke bot then make a nsfw bot then sell data on the darkweb?

#

hm do nuke bots really even break tos

upbeat otter
slate swan
#

Want a case?

#

🕴️

upbeat otter
upbeat otter
slate swan
manic wing
slate swan
#

Ill be one

#

On the grind if you know what I mean

manic wing
#

i dont.

upbeat otter
slate swan
raw latch
#

Guys I have a small problem with Discord buttons, if one guys is using a button, the bot respond to another server where the button was pressed previosuly.. what can i do?

slate swan
upbeat otter
slate swan
#

My dream job lol

upbeat otter
slate swan
#

Guys what commands should i do with buttons?

#

reactions > buttons

lost wolf
#

discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.economy' raised an error: SyntaxError: can't delete function call (economy.py, line 34)

#
    @commands.command(aliases=["deactivate"])
    async def cancel(self, ctx):
        users = await self.get_bank_data()
        user = ctx.author
        if str(user.id) in users:
            del users(user.id)
        else:
            await ctx.send("You dont have a account to deactivate.")
        with open("bank.json", "w") as f:
            json.dump(users, f)
#

code

slate swan
#

try del users[user.id]

cold sonnet
#

ideas for voicechannel commands?

slate swan
cold sonnet
slate swan
#

Buttons are better for sure

#

how do I remove the help from my bot and making my own

cold sonnet
#

!d discord.ext.commands.Bot.help_command

unkempt canyonBOT
cold sonnet
#

so inside commands.Bot(), you can set help_command=None

slate swan
#

in python

lost wolf
#

client/bot.remove_command("help")

cold sonnet
slate swan
#

ok

brazen raft
lost wolf
cold sonnet
#

not necessarily

brazen raft
#

Clients don't have the concept of commands

cold sonnet
#

well then yes

#

my bad

brazen raft
#

And they don't come with a default help command

#

Obviously

cold sonnet
#

but people would name discord.Client bot

#

so just in that case

#

wait what

brazen raft
slate swan
#

where do i need to put that

cold sonnet
#

they would name commands.Bot client

cold sonnet
#

inside commands.Bot, you put help_command=None

brazen raft
#

Misnaming is terrible especially in an API wrapper such as this because those two classes mean different things.

slate swan
cold sonnet
#

inside commands.Bot

slate swan
#

where is commands.bot

cold sonnet
#

B

brazen raft
#
from discord.ext import commands
bot = commands.Bot(help_command=None)
cold sonnet
#

yes

slate swan
#

ay thx

#

The help command kwarg is better than to remove it

cold sonnet
#

yes, because it's instant and doesn't need to invoke a line more

brazen raft
#

It is best to subclass commands.HelpCommand and pass it to help_command

slate swan
#

Imagine subclassing the help command

cold sonnet
#

imagine not

slate swan
#

I just make another command named helppithink

cold sonnet
#

well I don't have to imagine that

#

I'm dumb and always make a help command

slate swan
#

Same

#

Idk im to lazy to make a subclass

cold sonnet
#

and idk how I would do it

#

seems complicated

slate swan
#

it gives me errors

cold sonnet
#

well show the errors then

#

¯_(ツ)_/¯

slate swan
#
Traceback (most recent call last):
  File "c:\Users\Pasci\Documents\Netheritesmp.py", line 18, in <module>
    bot = commands.Bot(help_command=None)
TypeError: __init__() missing 1 required positional argument: 'command_prefix'
PS C:\Users\Pasci\Documents> 
cold sonnet
#

commands.Bot(help_command=None) is missing 1 required positional argument: 'command_prefix'

slate swan
#

w

#

ohh i get it i think

#

wait no

supple summit
#

i think

cold sonnet
#

I am not the one having the error

slate swan
#

huh

cold sonnet
supple summit
#

wrong reply lol

cold sonnet
#

and it's command_prefix

#

not commands

slate swan
#

any way to fix

cold sonnet
#

by putting that keyword argument there

slate swan
#

where

#

in the line

cold sonnet
#

oh god

slate swan
#
bot = commands.Bot(command_prefix="",help_command=None)
#

Smh

cold sonnet
#

!resources I wanted to say this long ago

unkempt canyonBOT
#
Resources

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

slate swan
#

ok

slate swan
upbeat otter
cold sonnet
#

str

devout iris
#

How can i add cooldown to my commands?

cold sonnet
#

there's a decorator

upbeat otter
cold sonnet
#

!d discord.ext.commands.cooldown

unkempt canyonBOT
#

@discord.ext.commands.cooldown(rate, per, type=discord.ext.commands.BucketType.default)```
A decorator that adds a cooldown to a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command")

A cooldown allows a command to only be used a specific amount of times in a specific time frame. These cooldowns can be based either on a per-guild, per-channel, per-user, per-role or global basis. Denoted by the third argument of `type` which must be of enum type [`BucketType`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.BucketType "discord.ext.commands.BucketType").

If a cooldown is triggered, then [`CommandOnCooldown`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandOnCooldown "discord.ext.commands.CommandOnCooldown") is triggered in [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") and the local error handler.

A command can only have a single cooldown.
cold sonnet
#

no

slate swan
#

it wont work

slate swan
#

This is giving me brain damage

#

i wanna remove that

#

Not the actual command

upbeat otter
slate swan
#

Your bot constructor

devout iris
cold sonnet
#

okay you're trolling

#

good

upbeat otter
slate swan
#

how do i remove it doe

slate swan
#

where is that

cold sonnet
#

without the token

slate swan
#

You said what🕴️

maiden fable
cold sonnet
#

I'm curious if you replaced your bot definition or put a 2nd one

slate swan
#

I swear if he named hes bot constructor client im going to lose it

#

like that

#

In imports

upbeat otter
slate swan
#

🕴️

cold sonnet
#

you've got a damn lot of unnecessary imports

slate swan
#

ik

#

Why is your bot constructor in your imports

cold sonnet
#

and not the knowledge of classes

slate swan
#

wait

#

Btw imports dont make you seem cool*

cold sonnet
#

it's Member, not member peepoCry

slate swan
cold sonnet
#

wait you have two

slate swan
#

Im done

#

no

cold sonnet
#

uh

maiden fable
slate swan
#

I called it🚶

#

ok

cold sonnet
slate swan
cold sonnet
#

okay we all stop bullying

slate swan
#

@slate swan remove the client variable completely

cold sonnet
#

and use your bot instead

slate swan
#

ok

#

ill try

upbeat otter
#

Why am I always ignored

slate swan
#

magic

cold sonnet
#

you just deleted your message

upbeat otter
slate swan
cold sonnet
upbeat otter
slate swan
upbeat otter
upbeat otter
unkempt canyonBOT
slate swan
slate swan
#

now it gives me this

cold sonnet
#

wait there's only one

slate swan
upbeat otter
slate swan
#

🚶

#

Hold up

#

I left my bot over night and it activated on ready 2 times wtf?

#

hmm

slate swan
#

Why?

cold sonnet
#

that's the point of not using it

#

discord API being unstable

slate swan
#

Ah i see

#

Probably cause of my wifi

#

I was installing a game so it probably got disconnected from the gateway

cold sonnet
slate swan
cold sonnet
#

once disnake gets me a voice receiving option

#

I'll do it

tacit horizon
#

shipit okimii pfp shipit

cold sonnet
#

!d discord.Member.bot

unkempt canyonBOT
#

property bot```
Equivalent to [`User.bot`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.bot "discord.User.bot")
cursive spindle
#

member.bot?

cold sonnet
#

so if member.bot

#

exactly

slate swan
#

how do i make my bot @ everyone

cold sonnet
#

I think

#

guild.default_role.mention does it

slate swan
#

im not stupid anymore

cold sonnet
#

I'm not sure if a simple
await ctx.send("@everyone") does the work

slate swan
#

it does

#

if it is not an embed

cold sonnet
#

probably

slate swan
#

ye it does

#

ty

#

ive got it working

marble rampart
#

how can i see whan someone is joining a voice room

#

i mean like an event

tacit horizon
#

what is disnake api

ornate otter
tacit horizon
#

huh

#

what is wrapper

#

;-;

slate swan
#

nvm

#

its broken again

ornate otter
sour lodge
#

how can I get all roles in the server?

slate swan
#

the bot is broken again

#

nvm

#

i got it working

torn sail
#

using threading you can run discord.py and flask at once so maybe you can do same for disnake

#

i have to use replit so to keep my bot running i ahve to do flask + uptime robot

sour lodge
#

how do I use this

echo lagoon
torn sail
#

oh with discord?

#

then idk

echo lagoon
#

like, the api. .

sour lodge
echo lagoon
#

lets say on some restful api event, id like the bot to send a message. . (i ended up using quart instead for that reason)

torn sail
echo lagoon
#

tho im still curious if you can still use flask for that?

sour lodge
torn sail
sour lodge
#

I just wanna print all the roles of a guild into the console for experiment purposes

torn sail
#

and what do u need help with

sour lodge
#

with how to get the list of all the roles in a guild

torn sail
#

its just guild.roles

sour lodge
#

so I can just write

print(guild.roles)
```?
torn sail
#

you said ur using dsicord.Client?

slate swan
#

client.loop.create_task(my_task(message))
hm

sour lodge
slate swan
#

how do I use this

torn sail
# sour lodge ye

then you would use message.guild.rolesif ur doing it in the on_message thing

sour lodge
#

Thanks

lyric tusk
#

Im wondering of how to make my bot give roles to new members and the admins of servers can choose what role is given. I also need this to work in multiple servers who will have different roles.

torn sail
#

well you could give them the role on_member_join and have a command which is admin only that could set the role to give which would be stored seperately by server

tacit horizon
#
ImportError: cannot import name 'utils' from 'musicbot'
#

why ;-;

sick birch
#

because musicbot.py probably doesn't have a function/class named utils

tacit horizon
#

but .....

sick birch
#

but what?

#

the IDE isn't giving any errors?

#

if you try to ctrl click on utils where does it lead you to?

tacit horizon
#

no were ;-;

sick birch
#

probably why

#

make sure musicbot.py actually has a class or function called utils

tacit horizon
#

i download this code from github

sour lodge
#

I don't understand what the roles parameter is suppose to be

slate swan
#

How can I check how many characters a whole file has?

#

txt/json

echo lagoon
sour lodge
#

like the role id or something else?

echo lagoon
# sour lodge like the role id or something else?

you'd convert a role id to a role object, or another simpler way for testing would probs be ctx.guild.roles[1] should return the first role in that guild,
you could have your command require a role as a param, but then you'll need to @ that role. . . (or maybe a check with written as words but some roles maybe harder to type out)

another method that i use is using ui, get the user to select a role from a list...

sour lodge
#

I am using discord.Client()

#
import discord

client = discord.Client()

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

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

  if message.content.startswith("!!test") and message.author.id == 489115020412715041:
    await message.author.add_roles()
echo lagoon
#

unless required, i would highly suggest moving to commands, it does make it alot easier

sour lodge
#

alright

echo lagoon
#

its really simple once you set it up!

sour lodge
#

I just wasnt confident with how it works

echo lagoon
#

yes, me too when i first started, made my first bot with client too, it was a nightmare!

#

second bot was without cogs, did a full rewrite and im on my third iteration . - .

sour lodge
#

lol, ima try commands now

cloud dawn
echo lagoon
#

welp, ill leave the rest for you to figure out, cant spoon feed, just a stepping stone

sour lodge
#

alright, thanks

echo lagoon
#

thx fixed it

sour lodge
#

👍

cloud dawn
sour lodge
#

whats that

cloud dawn
unkempt canyonBOT
echo lagoon
#

if i moved from dpy to disnake, do i need to do a full rewrite (from 2.0)

#

i got a lot of ui stuff too

manic wing
#

no

cloud dawn
#

Most of the stuff is just the name Discord to Disnake.

manic wing
#

just replace all discord -> disnake

sour lodge
sour lodge
#

so should I learn this instead of disocord.ext commands

echo lagoon
cloud dawn
sour lodge
#

oh so disnake is getting updated and discord.py isnt

cold sonnet
echo lagoon
cold sonnet
#

it's functioning

cloud dawn
cold sonnet
#

I'm not sure why I did it yet tho

#

I even forgot it 🤔

sour lodge
#

alright ima learn disnake then, thanks

cold sonnet
#

oh I know

#

I wanted role icons

echo lagoon
#

role icons? is that new

cold sonnet
#

yes

echo lagoon
#

requires boost?

cold sonnet
#

they're basically

#

emojis next to roles

cold sonnet
#

but you can farm boosts

#

with that steelseries giveaway

echo lagoon
#

how does one farm boosts?

cloud dawn
cold sonnet
#

what why

#

no

cloud dawn
cold sonnet
#

it's just a new account

cloud dawn
#

oh

cold sonnet
#

last 2 lines mean "only for new users of discord nitro"

#

it's like the epic games giveaway

echo lagoon
#

ig thats what you mean by farming boosts. . .

cold sonnet
tacit horizon
#

if someone open spoiler text can discord bot recognized it

cold sonnet
#

no

tacit horizon
#

this is not possible ?

cold sonnet
#

if you send me a spoiler text

#

and I open it

#

can you recognise it that I opened it?

tacit horizon
#

if discord bot send a spoiler test and i open it then can discord bot recognized ?

cold sonnet
#

no

#

you can't either

tacit horizon
cold sonnet
#

well the bot can't do anything that you can't either

#

except send embeds

manic wing
slate swan
tacit horizon
#

do u know any good bot source code

cold sonnet
#

meaning

#

it's a scam

tacit horizon
cold sonnet
#

friend said they'll give it back

#

since it's only for recognizing fake credit cards

dapper cobalt
unkempt canyonBOT
#
Bad argument

Unable to convert 'is the source code of @unkempt canyon.' to valid command, tag, or Cog.

dapper cobalt
#

!source

unkempt canyonBOT
cold sonnet
#

wasn't scoopy a dev of disnake?

dapper cobalt
#

No?

cold sonnet
#

you were the one selfpromoting

#

weren't u

dapper cobalt
#

I was promoting disnake because it's good, not because I'm its developer.

slate swan
#

Should this work? I want to check every hour if a specific Vanity is available and use it instantely. I will connect it to a loop. It's like a "Vanity-Sniper"

await asyncio.sleep(3600)
try:
    await guild.edit(vanity_code="cool-server")
except:
    print("Vanity already taken")
cold sonnet
#

but your pfp was the thumbnail of the github url when you linked it

dapper cobalt
#

Thought, I don't take it as promoting. People were just asking for good forks, so I recommended it.

dapper cobalt
slate swan
#

pandalove got my emoji's back

cold sonnet
#

that was quick

slate swan
#

hi panda

slate swan
cold sonnet
#

what's Vanity

slate swan
slate swan
slate swan
#

Just to annoy me

#

And sometimes his boost go lower than 14 but I miss it

#

You can't "steal" vanity URLS or you just don't have enough boosts.

#

Yea well mine went under 14 one time and since then he has my vanity

slate swan
#

but I'm over 14 again and now I want to "snipe" as soon as his boosts go lower then 14

slate swan
slate swan
#
class MyCog(commands.Cog):
    def __init__(self):
        self.printer.start()

    def cog_unload(self):
        self.printer.cancel()

    @tasks.loop(hours=1)
    async def printer(self):
        try:
            await guild.edit(vanity_code="cool-server")
        except:
            print("Vanity already taken")

Smth like this?

#

Don't bare except it.

#

Then it's all good.

#

so just

    @tasks.loop(hours=1)
    async def printer(self):
       await guild.edit(vanity_code="cool-server")
#

without try?

slate swan
#

Hmm

#

uhh

echo lagoon
#

question, does disnake allow you to add buttons at a specific row, so all other items get shifted a row (after view is created)?

slate swan
# slate swan uhh

!e ```py
test = {"t": "test"}

try:
test["s"]
except KeyError:
# The exception that is being raised
print('error')

unkempt canyonBOT
#

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

error
tacit horizon
#

react to messages commend

#

what is it

slate swan
#

How to get my discord bot's latency aka ms?

tidal hawk
#

Why does my task run after every 12 minutes IF its set for 180 minutes xD

tacit horizon
#

why not time.sleep

cloud dawn
unkempt canyonBOT
#

property latency: float```
Measures latency between a HEARTBEAT and a HEARTBEAT\_ACK in seconds.

This could be referred to as the Discord WebSocket protocol latency.
tidal hawk
cloud dawn
tacit horizon
cloud dawn
unkempt canyonBOT
#

coroutine asyncio.sleep(delay, result=None)```
Block for *delay* seconds.

If *result* is provided, it is returned to the caller when the coroutine completes.

`sleep()` always suspends the current task, allowing other tasks to run.

Setting the delay to 0 provides an optimized path to allow other tasks to run. This can be used by long-running functions to avoid blocking the event loop for the full duration of the function call.

Deprecated since version 3.8, removed in version 3.10: The `loop` parameter. This function has been implicitly getting the current running loop since 3.7. See [What’s New in 3.10’s Removed section](https://docs.python.org/3/whatsnew/3.10.html#whatsnew310-removed) for more information.

Example of coroutine displaying the current date every second for 5 seconds:
slate swan
#

@cloud dawn But is guild.edit(vanity_code="cool-server") right for changing the vanity?

cold sonnet
#

disnake @bot.user_command() cogs version?

#

also @bot.slash_command()?

tidal hawk
tacit horizon
tidal hawk
#

got it

#

my bad xd

slate swan
cloud dawn
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.
slate swan
cold sonnet
#

@commands.InvokableSlashCommand()?

cloud dawn
cold sonnet
#

and @commands.InvokableUserCommand

#

seems like it

cloud dawn
cold sonnet
#

lemme try that one

slate swan
cold sonnet
#

File "c:\botok\VCbot\cogs\menus.py", line 8, in Menus
@commands.InvokableUserCommand()
TypeError: init() missing 1 required positional argument: 'func'

manic wing
#

prob remove the ()

cold sonnet
#

hm

manic wing
#

idk what invokbleusercommand is tho

cold sonnet
#

disnake stuff

#

I'm just experimenting

#

seems to work on startup

#

command is not found

pliant compass
#

I'm making commands from a JSON file. My file looks like this:json [ { "name": "hello", "output": "Hello!" }, { "name": "goodbye", "output": "Goodbye!" } ] I have figured out how to make new commands, but I don't know how to make multiple. Here is my code:```py

Get data

def getData():
with open("customCommands.json") as jsonFile:
data = json.load(jsonFile)
return data

data = getData()
for command in data:

@commands.command()
async def newCommand(ctx):# Somehow change newCommand to command["name"]
    await ctx.reply(command["output"])
client.add_command(newCommand)

print(f"Added " + command["name"])
cold sonnet
#

once I make a new avatar command in the main file
disnake.ext.commands.errors.CommandRegistrationError: The command avatar is already an existing command or alias.

#

meaning it exists but it doesn't exist

floral crypt
cloud dawn
slate swan
cloud dawn
unkempt canyonBOT
#

Whether the commands should be case insensitive. Defaults to False. This attribute does not carry over to groups. You must set it to every group if you require group commands to be case insensitive as well.

cloud dawn
slate swan
cloud dawn
tacit horizon
cloud dawn
slate swan
tacit horizon
tacit horizon
slate swan
cloud dawn
tacit horizon
cloud dawn
tacit horizon
#

but i ;-;

cloud dawn
tacit horizon
#

its author.channel or something else ...

cloud dawn
cloud dawn
#

Yeah this message.channel = message.content idk what this is

tacit horizon
#

same

cloud dawn
pliant gulch
#

Therefor the bot has no ping

cloud dawn
#

Yeah makes sense lol

tacit horizon
#

why this is not working

#
if message.content == 'c':
        await message.add_reaction("\U0001F60E")
#

-_-

slate swan
#

The output is nan

pliant gulch
#

I don't need to see the full code to know that is the issue

#

Your bot.run should be at the bottom of the code, thus is ran last; Your print is before that

#

Meaning the bot isn't connected when you print the latency

pliant gulch
#

I know, that's what I just said

#

Did you even read what I said

slate swan
#

How is it not connected?

#

So u mean that i need to write bot.run above it?

pliant gulch
#

Your are connecting, just does it after the print

#

Therefor when the print is called it isn't connected yet

#

Therefor is NaN

slate swan
pliant gulch
#

Yes that would work

slate swan
#

and webhook sends it?

#

The message

pliant gulch
#

Do whatever

slate swan
#

K

slate swan
#

damn

#

how is tasks.loop blocking the code ffs

modern fiber
#

Hey guys. I'm looking to make a big Currency Bot with a very big system of mining and more. DM me if interested. It's very amazing idea.

torn sail
final iron
#

Send the code

quaint epoch
#

Does disnake also help with ping, or is this just a coincidence?

cloud dawn
mighty dust
#

if i do sort on a 2D array, what is it going to sort?

#

i have a 2d array of [[name, score],[name2,sccore2]] etc

#

i want to sort the score

#

oh why am i asking is discord bot sorry

cloud dawn
cloud dawn
crystal flint
#

If I want to make a bot that accesses a number from a command(eg. >>> sayhi 50) how would I code that?

sonic scarab
#

Hi

mighty dust
#

?

#

im new to using dictionaries sorry

cloud dawn
# mighty dust how do i sort once i get a dict

!e ```py
k = {
"player1": {
"score": 10
},
"player2": {
"score": 50
},
"player3": {
"score": 35
},
"player4": {
"score": 5
},
"player5": {
"score": 66
}
}

print(list(k.keys()))
print(sorted(k, key=lambda x: k[x]["score"]))

unkempt canyonBOT
#

@cloud dawn :white_check_mark: Your eval job has completed with return code 0.

001 | ['player1', 'player2', 'player3', 'player4', 'player5']
002 | ['player4', 'player1', 'player3', 'player2', 'player5']
mighty dust
#

holy shit

#

what is lambda

cloud dawn
mighty dust
#

oh ok

#

thanks

somber crown
#

are there any forks of discord.py v1.7.3 that can be used at the same time as discord.py v2? wether it be something like import discord, discordv1 or just a fork, i need both at the same time. let me know 🙏

somber crown
# boreal ravine just use one fork

im trying to have discord v1.7.3 znd discord v2.0 as 2 seperate imports, not to use in the same file, but to be able to operate old code sources without needing to uninstall and reinstall then uninstall and reinstall each time

somber crown
#

so something like

#file 1:
import discord```
```py
#file 2:
import discordv1```
boreal ravine
somber crown
#

u can have both versions at the same time?

slate swan
somber crown
#

cuz some of the attributes im trying to use arent working with the old sources when using dpy v2

boreal ravine
somber crown
#

does that not mean that the files already exist and no changes will be made?

#

or have i been looking at this the wrong way the whole time

boreal ravine
#

hm

somber crown
visual island
boreal ravine
#

which array should I use for a tree command for a marriage cog

quaint epoch
pliant gulch
#

Wouldn't the imports just overwrite each other

cloud dawn
#

Not trough pip

pliant gulch
#

So if you downloaded both version and imported discord you'd be able to use both versions???

#

That doesn't sound right

cloud dawn
#

You can just modify the name ofc

boreal ravine
#

how?

pliant gulch
#

This seems like a stupid problem anyhow

#

Why do you need both v2.0 and v1.7.3

cloud dawn
#

Then use local pip to install it as a local package.

somber crown
boreal ravine
somber crown
#

theres more than that but i wont go into details

boreal ravine
#

hm

pliant gulch
#

Sus

#

Not sure how requesting endpoints are version specific anyhow

sick birch
#

requesting endpoints, as in making http requests to them?

#

those are really just get/post requests and are independent of the d.py library

quaint epoch
#

how do i install pycord, by that i mean what version do i install? what is the command because i found quite a lot of them on pycharm

manic wing
#

!pypi pycord || pip install pycord

unkempt canyonBOT
manic wing
#

crap nvm

#

!pypi nextcord

unkempt canyonBOT
manic wing
#

is that the same thing?

#

brb lemme check

quaint epoch
#

so, do i just do py import pycord as discord from pycord.ext import commands because im honestly just too lazy to do anything else

manic wing
#

nono

#

!pypi py-cord || its this

unkempt canyonBOT
quaint epoch
quaint epoch
#

i installed pycord

manic wing
#

apologies

quaint epoch
#

its fine

manic wing
#

never used these forks

quaint epoch
#

So, i just tried this, discord.py got me around 100 ms ping, disnake around 50, pycord a little more than 50, and the results are constant? Are the forks meant to be faster like this?

#

or is it just me?

#

discord.py always got more ping in all of the tests

slate swan
#

Really depends on allot of things

quaint epoch
slate swan
#

Ig disnake is faster but it depends on the traffic of your wifi and many other stuff

slate swan
#

Idk maybe disnake is faster ig

quaint epoch
#

guess i'll stick to disnake

slate swan
#

But wait

quaint epoch
slate swan
#

Its not a good test youll have to check 10 times

quaint epoch
#

guess i have to uninstall pycord now

slate swan
#

If it does 50ms each try its 100%

#

Faster

#

Youll have to so many tries since it depends on many stuff it will be a good test

quaint epoch
#

oof the ping just spiked with pycord

#

im not going to filter out outliers im biased towards disnake lol

slate swan
#

Lol

#
def page_url(method, page:int=0):
    if method=="main":
        return f"https://www.curseofaros.com/highscores.json?p={page}"
    else:
        if method in ['mining', 'smithing', 'fishing', 'crafting', 'cooking', 'woodcutting']:
            return f"https://www.curseofaros.com/highscores-{method}.json?p={page}"

def stats(method, name):
    page=0
    while True:
        r= requests.get(page_url(method, page))
        if not r.text.strip()=='[]' and not ( r.text.strip())=='Not Found':
            for i in range(len(r.json())):
                if r.json()[i]['name'].lower()==name.lower():
                    stats=r.json()[i]
                    return stats
            page+=1
        else:
            raise Exception('Not Found')``` This requests is blocking my async program and making the bot process only one command at a time. How can I fix this mess? (I have only used requests for requests, I never tried urllib/aiohttp/httpx etc.)
south thicket
#

how can import file.py from folder in Github

manic wing
#

@quaint epoch

#

do lots of tests

#

like 50 for each

#

and then publish the results

south thicket
#

how can i import file.py from other directory in github

pulsar shell
slate swan
#

^

fathom heron
#

anybody know how to parse data from a user's input in a pytorch chatbot? Basically if the input is "whats the weather in tokyo" for example, how would I get that little "tokyo" bit?

manic wing
#

if disnake is faster i wanna fuckin know lol

#

uh

#

sent that a while ago

sick birch
pliant gulch
#

^

#

At the very least you would need to tokenize the sentence though

#

And then you'd parse those tokens

boreal ravine
#

which array should I use for a tree command for a marriage cog

blazing beacon
#

nextcord error but when i use d.py it works

maiden fable
#

Code

#

It should be async def panel

fathom heron
blazing beacon
#

mb

#

ty

tough lance
brave flint
#

discord.py last_boost.premium_since will return secs right?

boreal ravine
brave flint
#

yea checked the docs

maiden fable
#

U need to do ctx, *, entry

jade tartan
#
Traceback (most recent call last):
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 745, in call_soon
    self._check_closed()
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 510, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x00000229E4BF2200>
Traceback (most recent call last):
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 116, in __del__
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 108, in close
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 745, in call_soon
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 510, in _check_closed
RuntimeError: Event loop is closed```
#
async def close(ctx):
    await ctx.send(f"{client.user.name} has been shutdown")
    await client.close()```
sage otter
#

Ignore it, normal behavior on windows.

jade tartan
#

Yeah but it doesnt work

boreal ravine
#

what doesnt work

sage otter
#

The bot doesn’t close when you call .close() ?

#

It should be shutting down if it’s throwing that error.

jade tartan
#

well it didnt close the bot

#

its staying online

sage otter
#

Does it still respond to commands?

brave flint
#

i got error : AttributeError: 'Infos' object has no attribute 'say_permissions'
'Infos' was the cogs

boreal ravine
brave flint
#

uh

#

forgor

jade tartan
#

Yeah well doesnt respond to that

#

one

sage otter
#

ok, so if it doesn’t respond to commands then it did close then. It takes discord time to update shit. So it will look like it’s still online when it isn’t in some cases.

jade tartan
#

all other commands are working

#

but not this one

sage otter
#

That wasn’t my question….

jade tartan
#

Would it be fixed if i change the token?

sage otter
#

I’m asking after you call that method

boreal ravine
sage otter
#

Does it respond to commands

sage otter
#

It shouldn’t

#

Client.close() should never throw an error.

jade tartan
#

oh nvm its offline now

boreal ravine
#

k

jade tartan
#

but why does it do this error?

brave flint
boreal ravine
#

it isnt an error

brave flint
sage otter
#

Nothing you can do about it

boreal ravine
#

its just asyncio saying ur loop (the bot loop) closed

jade tartan
#

ohh ok

brave flint
#

not all things is error

jade tartan
#

So its not really a bot error?

brave flint
#

when ur bot on a vc it will show another error

boreal ravine
#

in*

jade tartan
brave flint
sage otter
#

That’s why you should have proper clean ups 👌

jade tartan
#

Can i make a login command?

#

and itll like go back online

brave flint
#

nope

#

if u shutdown the bot it was disconnected to discord anymore

#

u need to restart or run the code again

sage otter
#

You could always use a process manager like systemd or pm2 that auto-restarts when the process is killed.

boreal ravine
#

???

sage otter
#

Read their docs.

brave flint
#

docs is number 1

sage otter
#

systemd is standard for most Linux distros

carmine pilot
#

embed.add_field(name='’Coin toss', value='Play coin toss', inline=True)

Is there any other way to write this code?
Ex. Instead of embed.add_field what other way could I write this?

sage otter
#

pm2 tho is kinda iffy. You have to install node/npm/yarn/etc to install it.

boreal ravine
brave flint
#

i havent pushed my code but i turn off my vscode

sage otter
#

Open cmd/poweshell or something and cd to the directory that has your .git file in it then. Ez

brave flint
carmine pilot
carmine pilot
boreal ravine
carmine pilot
brave flint
carmine pilot
brave flint
#

embed.add_field(name='Coin toss', value='Play coin toss', inline=True)

#

i think that will be more cool

boreal ravine
#

yes

#

more readable

brave flint
#

yeah

carmine pilot
#

i need a more complex one tho

brave flint
#

and inline=False

brave flint
boreal ravine
brave flint
#

tryhard embedding then

carmine pilot
sage otter
#

still to this day I try to figure out why Embed.add_field() arguments aren’t positional.

brave flint
carmine pilot
boreal ravine
#

what

sage otter
#

?

brave flint
carmine pilot
#

Without easy code

boreal ravine
brave flint
boreal ravine
#

thats just embeds

brave flint
#

with only ytdl and ffmpeg

carmine pilot
carmine pilot
boreal ravine
brave flint
carmine pilot
#

wym

brave flint
carmine pilot
#

ohhhhh okk

brave flint
#

def create_embed(self):

#

like that right

boreal ravine
#

Thats a function though I said subclassing discord.Embed

sage otter
#

something like.

class EmbedSub(discord.Embed):
    … init shit
    self.add_field()
boreal ravine
#

yes

#

self being the embed obj

brave flint
#

yea because it was classed

carmine pilot
#

stack overflow has this

    async def on_ready(self):
        print('Logged on as {0}!'.format(self.user))

    async def on_message(self, message):
        if (message.channel.id == redacted):
                if "status code" in message.content:
                    print('Message from {0.author}: {0.content}'.format(message))```
carmine pilot
#

lol

boreal ravine
brave flint
#

wait but why when im resetted the bot those "Downloader cogs loaded" not shown

brave flint
boreal ravine
#

wait ur class is called Events, whats Downloader

brave flint
sage otter
#

I’m out 🚶

boreal ravine
sage otter
#

why’d you reply to me.

boreal ravine
#

wrong person

brave flint
brave flint
boreal ravine
# brave flint ah im bad at that

!e

class A:
  def do_stuff(self):
    print("Did stuff")

class B(A):
  def do_more_stuff(self):
    self.do_stuff()
    print("Did more stuff")

print(B().do_more_stuff())
``` an easy example of inheritance, bye now
unkempt canyonBOT
#

@boreal ravine :white_check_mark: Your eval job has completed with return code 0.

001 | Did stuff
002 | Did more stuff
003 | None
carmine pilot
#

kayle is @commands.command() the same as @bot.command()?

brave flint
carmine pilot
#

so i wouldnt use it normally correct

#

like without cogs

boreal ravine
unkempt canyonBOT
#

class discord.ext.commands.Command(*args, **kwargs)```
A class that implements the protocol for a bot text command.

These are not created manually, instead they are created via the decorator or functional interface.
brave flint
#

ah i got my problem

boreal ravine
#

h

carmine pilot
#

kayle

#

i got one

#

kayle = discord.Embed()

kayle.add_field….

await ctx.send(embed=kayle)

boreal ravine
#

yes what

tough lance
#

Wow such empty

gaunt ice
#
    
                               ^
SyntaxError: unexpected EOF while parsing```
#

this the error

#

and code keep_alive() bot.run(os.environ['Token']

boreal ravine
gaunt ice
#

ohh

boreal ravine
#

!e
print("h)

unkempt canyonBOT
#

@boreal ravine :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 1
002 |     print("h)
003 |           ^
004 | SyntaxError: unterminated string literal (detected at line 1)
gaunt ice
#

ohh

boreal ravine
#

ok but i think your error means you didnt close a string

gaunt ice
#

frig

#

the error

#

yes it fixed

boreal ravine
#

ah ok

gaunt ice
#

ty again

slate swan
#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

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

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

slate swan
#
Traceback (most recent call last):
  File "/home/container/.local/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "bot.py", line 183, in on_message
    embed=discord.Embed(color=0xff0000)
  File "/usr/local/lib/python3.8/json/__init__.py", line 293, in load
    return loads(fp.read(),
  File "/usr/local/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.8/json/decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 15 column 6 (char 263)``` can sameone help pls
slate swan
#

remove , at the ending

#
{
   "739861800769552525":{
      "791583999361155092":{
         "experience":7,
         "level":1
      },
      "689461924038967346":{
         "experience":626,
         "level":5
      },
      "814226043924643880":{
         "experience":538,
         "level":4
      }
   }
}``` should look like this
#

oh

heavy folio
slate swan
#

but why

#

is not good

heavy folio
slate swan
#
    guild = client.get_guild(756504534897000528)
    while True:
        for member in guild.members:
            try:
                if member.nick.startswith("✨"):
                    pass
                else:
                    await member.edit(nick=f"✨・{member.display_name}")
            except:
                pass

I want it to stop if everyone is done, How do I do that?

boreal ravine
heavy folio
#

oh

boreal ravine
slate swan
torn sail
slate swan
#

nvm it works

boreal ravine
slate swan
boreal ravine
weary gale
#
async def on_member_join(member: discord.Member):
    role = member.guild.get_role(8912345321432145942)
    role = member.guild.get_role(123321432321123)
    await member.add_roles(role)```
why does this not work?
#

it only gives a member the second role on join

torn sail
#

So change one of the role to a different name

boreal ravine
#

second variable overwrites the old one

torn sail
#

^^

weary gale
#

right

boreal ravine
#

!e
role = "value"
role = 1
print(role)

unkempt canyonBOT
#

@boreal ravine :white_check_mark: Your eval job has completed with return code 0.

1
weary gale
#
async def on_member_join(member: discord.Member):
    role1 = member.guild.get_role(893297001897295942)
    role2 = member.guild.get_role(921597725215178783)
    await member.add_roles(role1, role2)```
could i do this
torn sail
#

Should work

weary gale
#

thx

quick kindle
#

Yo guys I got a problem

#

a syntax error in my code

torn sail
#

Should show code

quick kindle
boreal ravine
#

its class music

quick kindle
#

import discord
from discord.ext import commands
import youtube_dl

class.music(commands.Cog):
def init(self, client):
self.client = client

@commands.command()
async def join(self, ctx):
if ctx.author.voice is None:
await ctx.send("You're not in a voice channel")
voice_channel = ctx.author.voice.channel
if ctx.voice_client is None
await voice_channel.connect
else:
await ctx.voice_client.move_to(voice_channel)

@commands.command()
async def disconnect(self, ctx):
await ctx.voice_client.disconnect()

@commands.command
async def play(self,ctx,url):
ctx.voice_client.stop()
FFMPEG_OPTIONS = {'before-options': '-reconnect l -reconnect_streamed l -reconnect_delay_max 5', 'options': '-vn'}
YDL_OPTIONS = {'format':'bestaudio'}
vc = ctx.voice_client

      with youtube_dl.YoutubeDL(YDL_OPTIONS) as ydl:
         info = ydl.extract_info(url, download=False)
         url2 = info['formats'][0]['url']
         source = await discord.FFMpegOpusAudio.from_probe(url2, **FFMPEG_OPTIONS)
          vc.play(source)

@commands.command()
async def pause(self, ctx):
await ctx.voice_client.pause()
await ctx.send('Paused ⏸')

@commands.command()
async def resume(self, ctx):
await ctx.voice_client.resume()
await ctx.send('Resumed ▶️')

def setup(client):
client.add_cog(music(client))

boreal ravine
#

bruh.

quick kindle
#

any solutions?

boreal ravine
#

I sent one

#

scroll up

quick kindle
#

r u sure?

boreal ravine
#

yes I'm sure

torn sail
boreal ravine
#

basic OOP

quick kindle
#

then also there is a problem

#

and the program isn't running

torn sail
#

Also shouldn’t def init be def __init__

boreal ravine
#

and im positive keywords dont have something after them, ```py
pass #correct
pass.do_shit() #wrong

quick kindle
#

discord has messed that part of code

boreal ravine
torn sail
#

Oh nvm

#

Yeah just noticed that

quick kindle
#

guys

boreal ravine
quick kindle
boreal ravine
#

its class music

#

not classmusic

torn sail
#

Yes

quick kindle
#

oh ok

torn sail
#

With space

quick kindle
#

but still

boreal ravine
#

show

quick kindle
boreal ravine
#

functions must be on the same line you used a decorator

torn sail
#

Yeah no indent after the decorator

boreal ravine
#
@stuff
async def func():
   ... #correct

@stuff
   async def func():
     ... #wrong
quick kindle
#

oh

#

Now wht?

torn sail
#

You need a colon

#

Shouldn’t you know that!?

quick kindle
#

I thought giving colons was the problem so I removed it

torn sail
#

Go the the replit packaging thing on the left side and add discord.py

quick kindle
#

uhhh

#

i forgor

#

bruhh

#

wait a min

#

i already have it downloaded

torn sail
#

There’s another discord.py in the packaging thing. Try adding that

slate swan
#

Btw your commands arent gonna be found lol

quick kindle
#

what?

slate swan
#

Your commands arent indented

#

They should be indented with the function

#

Inside of the class

quick kindle
#

doesn't python do auto indentation?

boreal ravine
#

no

quick kindle
#

like

#

i regret making a bot now

boreal ravine
#

go learn python now yes

torn sail
#

Yes

quick kindle
#

im aiming for js now no hate to python whatsoever

slate swan
#

Python isnt hard really

quick kindle
#

lemme just check what the matter with python indentation is

slate swan
#

Its always 4 if your trying to follow pep8

#

!pep 8

unkempt canyonBOT
#
**PEP 8 - Style Guide for Python Code**
Status

Active

Created

05-Jul-2001

Type

Process

quick kindle
#

oh

boreal ravine
#

the commands must be inside the class for the command to register

quick kindle
#

before that

#

i wanna ask yall if this vid shows proper indentation

boreal ravine
#

it does

#

you didnt copy it right