#discord-bots

1 messages · Page 986 of 1

slate swan
#

😂 thats exactly what the website does, seems like you just saw that "use this to run the bot 24/7" and followed what they asked to do without researching things

pure sparrow
#

I agree

slate swan
#

enough to get replit blacklisted

pure sparrow
slate swan
#

they stopped accepting replit urls for a while

cloud dawn
rapid jetty
#

Hey, I know a free host

vocal plover
rapid jetty
#

oh

#

hey, uhhhh, I work on discord.py v2 and wanna know if someone want to work with me

cloud dawn
#

When collaborating people are interested in.

  • Your skill level
  • GitHub
  • Hosting
  • What
#

Could you delete this? Since I don't think this is something friendly.

swift crane
#

yeeeeeeees

#

i did it

#

❤️

velvet haven
#

How to set cooldowns for commands

slate swan
#

use the @commands.cooldown decorator

#

!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.
wheat prawn
#

add @commands.cooldown(...)

swift crane
#

@junior verge @maiden fable @sick birch @vocal plover thx for help 🫀

#

and sorry for ping

#

good night

rapid jetty
cloud dawn
#

Robin loves to get pinged dw

velvet haven
#

What's bucket type

rapid jetty
#

Type of cooldown

slate swan
#

the type of cooldown you want to implement

cloud dawn
#

!d discord.ext.commands.BucketType

unkempt canyonBOT
velvet haven
#

Oh

slate swan
#

can be a user/guild/channel bucket

#

member/category and role too

rapid jetty
#

Like, if its commands.BucketType.user is a cooldown to each user, if it is commands.BucketType.channel is a cooldown to the channel and if it is commands.BucketType.guild is a cooldown to the guild

eager bough
#

(:

#

im back

cloud dawn
#

Anyone up for a challenge? ||aka my problem lol||

slate swan
#

@bot.event
@event.cooldown(1, 15, event.BucketType.user)```
Hello my code says event isn’t defined when it clearly is
cloud dawn
#

Not event.BucketType.user

slate swan
#

Ok

cloud dawn
#

from discord.ext.commands import BucketType this for the next error

slate swan
cloud dawn
#

lemme grab the docs

#

It's just cooldown not event

#

You also can't apply a cooldown on an event

pure sparrow
slate swan
#

Is there another way to do it

cloud dawn
# pure sparrow what is your problem man ?

Got Pycharm error Unnecessary non-capturing group '(?:Overview:\s+)'
Using re (?:Overview:\s+)(?s:.)*(?=\WThread) ```py
Overview:
lorem ipsum text etc

should still catch here

Thread until here catching the word thread

pure sparrow
#

Yeah I think youtube_dl is not welcome in that server..

cloud dawn
pure sparrow
cloud dawn
cloud dawn
sick birch
#

I uh don't remember helping

cloud dawn
#

Robin you got experience with re groups?

pure sparrow
cloud dawn
pure sparrow
#

very strange... I never used pycharm so Im scared i won’t be able to help you that much but I will do my best...

cloud dawn
#

I tried removing the group but then the re won't match for some reason.

pure sparrow
#

why does that warn appeared ?

cloud dawn
#

Since it doesn't want me to group (?:Overview:\s+)(?s:.)*(?=\WThread)

pure sparrow
#

Oh ok

#

this is a part of your code right ?

cloud dawn
#

Yeah it is

#

re.findall(r"(?:Overview:\s+)(?s:.)*(?=\WThread)", self._desc)

#

self._desc == the lorem text or in this case the test case.

pure sparrow
#

hmm by any chance you didn’t forgot anything ?

#

Like a « , » or anything ?

cloud dawn
#

What is »?

#

!charinfo »

unkempt canyonBOT
pure sparrow
#

Im French I don’t know how we call it in English 😅

sick birch
cloud dawn
pure sparrow
#

ok thanks 🙏🏻

sick birch
cloud dawn
#

See what i did there py_guido

#

😏

slate swan
cloud dawn
cloud dawn
pure sparrow
#

Anyone coding on Pycharm to help him ?

sick birch
slate swan
rocky hornet
#

how can i play an in-memory ogg file?

cloud dawn
#

@pure sparrow I fixed it

#

I removed the group then used a single search that returns a re object then cast to string ```py
str(re.search(r"(Overview:\s+)(?s:.)*(?=\WThread)", self._desc))

pure sparrow
rocky hornet
cloud dawn
rocky hornet
#

it wont

#

.group() is the matched part

cloud dawn
#

True but it returns the same.

rocky hornet
#
>>> str(re.search("uwu", "amoguwusu"))
"<re.Match object; span=(4, 7), match='uwu'>"
cloud dawn
#

oh yeah lol

rocky hornet
#

so you didnt even test it

#

but u guessed that it returns the match

cloud dawn
#

I did but it was a small desc and I overread.

#

Thanks :3

rocky hornet
#

np

cloud dawn
#

I'm extracting data from a website but it's a literal hell since it's pretty inconsistent :(

rocky hornet
#

use beautiful soup

#

to parse html

cloud dawn
#

Or even text outside tags

rocky hornet
#

whatever suits you best

cloud dawn
static lintel
#

hey i was wondering if there is a way for me to search for something through my discord bot by adding what i want to search after the command instead of sending a separate message of what i want to search up.
ie;
what i currently have:
me: ..search
discordbot: what do you want to search?
me: google

what i want to do:
me: ..search google
discordbot: desired search results

slate swan
#

just use an argument

#

and if you want to search for something in google just use their api

static lintel
#

sorry that was just an example but im just curious if its possible to make the command one message instead of two

slate swan
#

yes an argument after the context argument just add another one which if you just want the word of the platform you want to search with a positional argument would do fine.

static lintel
#

oh ok i think i understand what you mean. will test to see if i understood what u said correctly and then check back here again if i need further help. ty! ❤️

slate swan
#

!args-kwargs

unkempt canyonBOT
#

*args and **kwargs

These special parameters allow functions to take arbitrary amounts of positional and keyword arguments. The names args and kwargs are purely convention, and could be named any other valid variable name. The special functionality comes from the single and double asterisks (*). If both are used in a function signature, *args must appear before **kwargs.

Single asterisk
*args will ingest an arbitrary amount of positional arguments, and store it in a tuple. If there are parameters after *args in the parameter list with no default value, they will become required keyword arguments by default.

Double asterisk
**kwargs will ingest an arbitrary amount of keyword arguments, and store it in a dictionary. There can be no additional parameters after **kwargs in the parameter list.

Use cases
Decorators (see !tags decorators)
Inheritance (overriding methods)
Future proofing (in the case of the first two bullet points, if the parameters change, your code won't break)
Flexibility (writing functions that behave like dict() or print())

See !tags positional-keyword for information about positional and keyword arguments

velvet haven
#
@commands.command(name="leave",help="Leaves the server")
@commands.is_owner()
async def leave(self, ctx, *, guild_name):
      guild = discord.utils.get(self.client.guilds, name=guild_name)
      if guild is None:
        await ctx.send("I don't recognize that guild.")
        return
      await self.client.leave_guild(guild)
      await ctx.send(f":ok_hand: Left guild: {guild.name} ({guild.id})")```
#
attribute error : bot has no attribute "leave_guild"```
slate swan
#

thats not the right method

#

!d discord.Guild.leave

unkempt canyonBOT
#

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

Leaves the guild.

Note

You cannot leave the guild that you own, you must delete it instead via [`delete()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.delete "discord.Guild.delete").
velvet haven
#

i want the bot to leave the server when call the command

slate swan
#

yes?

velvet haven
slate swan
#

and i would recommend you just give a snowflake so then you could just get the guild with your bot instance so then you dont need to use utils which it iterates through all guilds

slate swan
#

you cant leave a guild for a member, only ban/kick the member, the coroutine that has been given is for your bot

#

!d discord.ext.commands.Bot.get_guild | this uses dict.get which i think its a hash lookup im not sure as its average time comp is O(1) and its worse case is O(n)

unkempt canyonBOT
slate swan
#

but its still better than using utils as the bot class already has a method for it, yes you could use utils for names etc but you can just use a for loop but i still wouldnt recommend it

slate swan
#

i hate how i close my mobile client on a thread and then when i open it again i get riderected to the default guild channel smh

torn sail
#

Remove the ()

solar seal
#

does anyone have an article or something that i can look at that shows how to write slash commands for discord.py?

muted cliff
#

hello

slate swan
#

it has examples

solar seal
#

thx

muted cliff
#

i need help

slate swan
#

with?

muted cliff
#

on discum code

slate swan
#

sorry, we dont help with that wrapper here nor with self bots.

muted cliff
final iron
unkempt canyonBOT
#

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

solar seal
#

how instant is syncing slash commands to a specific guild?

boreal ravine
solar seal
#

ok

slate swan
boreal ravine
#

but it sometimes takes a couple of seconds, depends on the library you're using

solar seal
#

oh then mine just isnt syncing for some reason

#

nvm im being an idiot

#

nope i literally just can't do slash commands

slate swan
rare saddle
#

Hello, can I somehow use the bot to download all the images that are in the chat? (only images in the chat, no text)

#

Or if there is already such a bot, its name please

oblique adder
#

nextcord !
can SlashOption choices be a function which return a dict ?

solar seal
#

is anyone able to give me some pointers on doing slash commands with discord.py as they don't seem to sync to my server at all

solar seal
#

yeah basically they don't show up

pliant gulch
#

Have you invited the bot to your guild with the application.commands scope?

#

You bot requires this scope to be enabled in order to even register commands

solar seal
#

yes i forgot that at first but it has that now

pliant gulch
#

You should probably show the code in question & any errors you get

solar seal
#

ok

#

what was that paste site again that people use to paste their code in?

pliant gulch
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

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

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

solar seal
#

thats it thx

#

bear in mind this code is gonna look bad because i just couldn't figure it out and started trying random stuff

grave summit
#

is it possible to only allow people with a certain role to use my bot

solar seal
#

ok then.....

slate swan
unkempt canyonBOT
#

@discord.ext.commands.has_role(item)```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member invoking the command has the role specified via the name or ID specified.

If a string is specified, you must give the exact name of the role, including caps and spelling.

If an integer is specified, you must give the exact snowflake ID of the role.

If the message is invoked in a private message context then the check will return `False`.

This check raises one of two special exceptions, [`MissingRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") if the user is missing a role, or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") if it is used in a private message. Both inherit from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").

Changed in version 1.1: Raise [`MissingRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")...
solar seal
#

anyone willing to actually help me with slash commands without just disappearing?

silver wolf
solar seal
#

ok so how exactly am i syncing the command is it through putting this?
await tree.sync(guild=discord.Object(id=MY_GUILD_ID))

grave summit
#

im v new so please excuse any absolutely stupid mistakes

solar seal
silver wolf
# solar seal ok so how exactly am i syncing the command is it through putting this? await tr...

well first u dont need 2 clients. u only need 1

bot = commands.Bot(command_prefix="?", intents=discord.Intents.all())

2: No need to manually create a tree because commands.Bot already comes with one. So u can create ur slash command like so

@bot.tree.command(name="...", description="...", guild=discord.Object(id=...))
async def test(inter: discord.Interaction):
     ...
  1. Put the sync in on_ready
async def on_ready():
    await bot.tree.sync(guild=discord.Object(id=...))

Now i've been told put the sync in on_ready, ive been told to not do it in on_ready, idk but it works for me

vital whale
#

Hello, is anyone available that can help a beginner?

I have this code:

elif message.content == "!list": f = open('output.rtf', 'w') movies = plex.library.section('Movies') for video in movies.all(): await message.channel.send(video.title)

that sends a message for each movie I have on my plex server. However, I'd like it to send as one message. It currently sends one message per movie, which at 800 movies takes forever. Is there a way for it to send as one message? I have tried outputting it to a txt file and sending that file, but even though the file is complete, once it is sent through discord the list is incomplete up to the same movie every time.

silver wolf
#

But that's just me. Idk if thats a good way to do it or not, but it works

torn sail
#

Not any big change

#

Also u should use the async with bot: context manager to make sure the bot cleans up properly

silver wolf
grave summit
#

ive tried googling it but cant find it

solar seal
#

ok i got a slash command to work for me

silver wolf
solar seal
#

now i just need to figure out how to do this with things other than message responses

silver wolf
#

wdym?

solar seal
#

like banning etc

grave summit
#

im trying to make my discord bot private so nobody can add it to their servers but its coming up with, cannot add install fields on private application

#

anyone know the resolution for thi

#

im not sure what is meant by install fields

solar seal
grave summit
solar seal
solar seal
supple thorn
grave summit
#

on the site, im getting a red bar at the top

solar seal
#

yeah i am trying to convert my code to slash commands now

solar seal
grave summit
#

"Cannot have install fields on a private application"

boreal ravine
solar seal
buoyant zodiac
#

!d discord

unkempt canyonBOT
#

In order to work with the library and the Discord API in general, we must first create a Discord Bot account.

Creating a Bot account is a pretty straightforward process.

solar seal
#

i am not sure then

torn sail
solar seal
#

i have like no clue how to ban with slash commands at the moment

torn sail
grave summit
solar seal
boreal ravine
boreal ravine
torn sail
solar seal
#

i don't know how to do that, literally anything to do with slash commands has literally just driven me mad

slate swan
#

I don't understand why this won't work

embed.set_thumbnail(url=ctx.channel.guild.icon.url)

error

AttributeError: 'NoneType' object has no attribute 'url'
boreal ravine
buoyant zodiac
#

ctx.guild.icon_url

slate swan
#

ohh

#

aight

buoyant zodiac
#

its .url???

boreal ravine
#

it changed in newer versions

buoyant zodiac
#

ohh

grave summit
#

how can i restrict bot usage to only members with the bot role

#

sry ive asked this before but just bumping it

solar seal
#

its on the documentation it shows how its done

solar seal
lost lichen
#

how can i send a custom emoji from a different server that the bot is in? using disnake

solar seal
#

it would be nice if people just said they were going rather than saying nothing and disappearing

#

because then we are just waiting here thinking they could come back when we could be figuring out how to sort our code

boreal ravine
solar seal
#

that doesn't work btw

#

or maybe it does

boreal ravine
#

I see no reason why it would it not work

solar seal
#

yeah it does ok

solar seal
#

i mean if anyone has any ideas please let me know

slate swan
#

!d discord.ext.commands.is_owner use this decorator

unkempt canyonBOT
#

@discord.ext.commands.is_owner()```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that checks if the person invoking this command is the owner of the bot.

This is powered by [`Bot.is_owner()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.is_owner "discord.ext.commands.Bot.is_owner").

This check raises a special exception, [`NotOwner`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NotOwner "discord.ext.commands.NotOwner") that is derived from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
slate swan
#

Youre using Disnake right?

solar seal
#

no

slate swan
#

is that a slash command or a normal one?

solar seal
#

slash command

slate swan
grave summit
#

i have read the documentation on the @commands.has_role, but still not sure on what i need to put to implement this

solar seal
#

i am pretty sure that won't since thats not formatted correctly for discord.py

grave summit
#

@commands.has_role('Machiavelli')

#

so far i have that so that only people with that role can use my bot😂 not sure what else i would need to put

torn sail
torn sail
#

!d discord.app_commands.check

unkempt canyonBOT
#

@discord.app_commands.check(predicate)```
A decorator that adds a check to an application command.

These checks should be predicates that take in a single parameter taking a [`Interaction`](https://discordpy.readthedocs.io/en/master/interactions/api.html#discord.Interaction "discord.Interaction"). If the check returns a `False`-like value then during invocation a [`CheckFailure`](https://discordpy.readthedocs.io/en/master/interactions/api.html#discord.app_commands.CheckFailure "discord.app_commands.CheckFailure") exception is raised and sent to the appropriate error handlers.

These checks can be either a coroutine or not.

Examples

Creating a basic check to see if the command invoker is you...
inland shell
#

how do u run a python discord bot on your computer using python? can someone help me?

grave summit
# unkempt canyon

ive read this but still not sure what i need to put for the function of that command for has_role

slate swan
solar seal
slate swan
#

if you are on a windows system you are likely to have py as your python namespace

grave summit
cloud dawn
inland shell
# slate swan `python/py <filename>.py` is the most common way

I recently got a new PC and my old pc had python installed on it and when someone made a discord bot for me they told me how to run it but now on my new pc i dont know how to re install python and i installed it using there website and added the PATH option but when ever I open the bot file it automatically closes

slate swan
quaint epoch
inland shell
cloud dawn
slate swan
inland shell
#

python automatically closes when I press it

slate swan
sick birch
inland shell
#

Thats what it says

slate swan
#

clearly said, python/py

sick birch
#

Ah, is it py on windows?

slate swan
inland shell
sick birch
#

Correct me if I'm wrong, I'm only familiar with the python3 ... way to do it

slate swan
#

they work same except for the namespace

sick birch
#

Great, then just use py instead of python3

#

But whoever gave you that discord bot should've probably dockerized it

wicked atlas
inland shell
slate swan
supple thorn
inland shell
#

no it elias lol

supple thorn
#

Nice

inland shell
#

its a hispanic name

sick birch
inland shell
supple thorn
sick birch
#

What happens when you run py bot.py?

supple thorn
#

In the username

sick birch
inland shell
supple thorn
wicked atlas
sick birch
#

Oh yeah that makes sense

inland shell
#

im in command prompt

sick birch
#

Navigate to the directory that your file is in

#

using cd

inland shell
#

what i type

sick birch
#

Where's your file located? Like what's the path?

inland shell
sick birch
#

In your downloads

#

so type in cd Downloads

inland shell
#

done

sick birch
#

Your prompt should change to

C:\Users\<username>\Downloads>
#

Yes?

#

Then you can run the command py bot.py

inland shell
sick birch
#

Looks like your person didn't tell you how to get all the dependencies

#

Did they provide any other files or just bot.py?

slate swan
inland shell
#

just bot.py it worked on my other laptop with him just sending the file.

slate swan
#

Oh its solved

unkempt canyonBOT
slate swan
#

py -m pip install discord.py

sick birch
#

Or dockerized it which is the preferred way

#

But I'm going to assume the only dependency is discord.py

#

In which case so as Sarth said to get that installed

slate swan
#

or poetry 🗿

inland shell
sick birch
#

And putting everything in one file isn't the best but it works I suppose

#

I sure hope you didn't pay that person to make you the bot

inland shell
#

its done installing it

cloud dawn
sick birch
#

Explains why they're low quality 99% of the time

inland shell
#

and i did pay the person to make the bot and it works really well for what I need it has 3rd party APIs interegated in it

inland shell
#

what now its done installing

opal cosmos
#

how to do listener event in cog?

slate swan
inland shell
#

Oh it works

sick birch
inland shell
#

Its opening the file and hosting the bot

sick birch
#

Cool, looks like discord.py was the only dependency

#

Still don't really agree with the whole thing but it works

inland shell
#

is there anyway to host it 24/7 without my computer

opal cosmos
#

thx

sick birch
#

Yeah, buy a VPS

cloud dawn
sick birch
#

Yeah that exists now doesn't it

inland shell
#

Alright thanks for the help. Peace ✌️

opal cosmos
#

wow, turns out i only need one on_error event for all cogs

sick birch
#

Be careful about global error handlers

opal cosmos
#

lol yeah

sick birch
#

If you're not they'll end up eating all your errors

cloud dawn
opal cosmos
#

lol

polar ice
#

Hello is anyone available to offer any advice? I've got a loop, which works perfectly but only the first I run the code.
When the loop comes back round it doesn't seem to do as it should which is retrieve the data from the SQL DB

Can anyone shed any light to what im doing wrong?
https://paste.pythondiscord.com/butaritawo

I've posted the actual loop itself and also the first function. any help would be greatly appreciated.

Could it be because im using aysnc tasks

Desperately need help trying to figure out why it isnt working now 😦

opal cosmos
#

why wont my bot send emoji?

#
  @commands.Cog.listener()
  async def on_command_error(self, ctx, error):
    if isinstance(error, commands.CommandOnCooldown):
      msg = ">:Error:966148323725705246< __**On cooldown**__, please try again in `{:.2f}s`".format(error.retry_after)
      await ctx.send(msg)
sick birch
#

That's not a default discord emoji

opal cosmos
#

ok

#

but its one that the bot is in

#

like its from a server the bots in

quaint epoch
frozen patio
#

How does it net exist when it does exist....

quaint epoch
#

i tried to make as easy to use as possible, just copy the repos, host and you're set

quaint epoch
frozen patio
quaint epoch
opal cosmos
sick birch
opal cosmos
#

but if i did it right then it would change it on discord to just :Error:

frozen patio
quaint epoch
sick birch
opal cosmos
sick birch
#

In a cog, it'd be self.bot.get_emoji()

opal cosmos
#

ok

sick birch
#

Given that you set self.bot = bot in your cog constructor

opal cosmos
#

ye

opal cosmos
sick birch
#

ID

#

!d discord.Client.get_emoji

unkempt canyonBOT
#

get_emoji(id, /)```
Returns an emoji with the given ID.

Changed in version 2.0: `id` parameter is now positional-only.
opal cosmos
# sick birch !d discord.Client.get_emoji

f-string not allowed

  @commands.Cog.listener()
  async def on_command_error(self, ctx, error):
    if isinstance(error, commands.CommandOnCooldown):
      emoji = self.bot.get_emoji(id=966148323725705246)
      msg = f"{emoji} __**On cooldown**__, please try again in `{:.2f}s`".format(error.retry_after)
      await ctx.send(msg)
sick birch
#

Either use all f strings or all .formats() dont mix and match

frozen patio
cloud dawn
opal cosmos
boreal ravine
sick birch
final pumice
#

should I ditch discord.py and move to another wrapper

sick birch
opal cosmos
cloud dawn
opal cosmos
#

also

sick birch
opal cosmos
#

bot now says this for cooldown message:

None On cooldown, please try again in 28.19s

#

no emoji

sick birch
#

And you're sure the ID is a valid ID of the emoji?

opal cosmos
#

yes

boreal ravine
opal cosmos
cloud dawn
opal cosmos
sick birch
boreal ravine
#

yikes

opal cosmos
#

but then what do i do, the emoji wont work

sick birch
#

Better to find best practices yourself because ones that come from other people may or may not be accurate

opal cosmos
#

ok

sick birch
#

How did you find the ID?

frozen patio
cloud dawn
opal cosmos
#

i have developer mode turned on and right clicked on the moji and clicked copy id

frozen patio
#

It shows the table exists

boreal ravine
final pumice
frozen patio
cloud dawn
#

Back again

sick birch
#

There was a gist a while back on resuming development

sick birch
final pumice
#

oh, so he's continuing development?

opal cosmos
#

kk

boreal ravine
sick birch
sick birch
final pumice
#

sick, thanks

opal cosmos
#

:Error:

#

thats all it shows

sick birch
#

Hmmm

#

That's strange

#

And it's a custom emoji?

opal cosmos
#

yeah

sick birch
#

Try clicking on the emoji from the selector first, then put a backslash before it

opal cosmos
#

still nothing

#

do u wanna join the server and try it? bcs im not getting anywhere

#

XD

sick birch
#

I'm good thanks, I'm stumped as well

#

That's strange behaviour for custom emojis

opal cosmos
#

ikr

#

checking my other bots code to see if theres anyt difference

frozen patio
frozen patio
#

Well the databases are not letting me

boreal ravine
#

you did something wrong..

frozen patio
#

But what?

#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

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

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

frozen patio
#

Okay I will use that to show my code

opal cosmos
#

@sick birch ...

idk how but i think the id changed somehow? its the same emoji but the id is different now

polar ice
boreal ravine
frozen patio
#

Yes

boreal ravine
#

that wasn't a yes or no question

frozen patio
#

Oh

#

I thought I needed to commit both of them

#

separately

#

@boreal ravine I removed it, still same error

boreal ravine
frozen patio
#

And redoing them?

opal cosmos
#

ima just use default emojis for now

boreal ravine
frozen patio
boreal ravine
frozen patio
#

Ah

#

So let the algorithm make it?

boreal ravine
#

yes

frozen patio
#

@boreal ravine Nope

boreal ravine
#

same error?

frozen patio
#

Yes

#

Is this causing it?

boreal ravine
#

yes

#

the last setattr overwrites the old attribute

#

why're you even using setattr anyways?

frozen patio
#

Oh

#

Because that is how I set them up

#

How do I make these 2 work together?

boreal ravine
#

create multiple tables inside one file

frozen patio
#

Oh, is that how I have to do it

#

I cannot make different files in 1 on_ready statement?

boreal ravine
#

possible, or just ```py
bot.afk_db = ...
bot.level_db = ...

frozen patio
#

How can I do that then?

boreal ravine
#

you just did in your code..

frozen patio
#

Hmm

#

I need to make both connect, can I do that in the setattr line?

slate swan
#

How can my bot, count the messages of every server but if the command is used, it tells you how many messages were sent in that specific server? and not global? because currently it counts of every server and sends how many messages were sent in every server

frozen patio
#

Your bot is verified?

slate swan
#

yes

frozen patio
#

Good Job

slate swan
#

thanks

frozen patio
#

A dream of mine

slate swan
#

Yea it was my dream too till i realized they removed the bot developer badge

frozen patio
#

Damn, why?

slate swan
slate swan
sick birch
#

Using .history()

frozen patio
cyan hare
#

need help with this\

cloud dawn
#

Can't see much

#

I can see a token tough py_guido

#

Might be worth resetting..

cyan hare
#

it reseted dont worry

#

wdym u dont see much

olive osprey
# cyan hare

Looks like you're ratelimited, are you on replit?

cyan hare
#

if so i screenshot

cyan hare
#

is there way to fix this

olive osprey
#

Alright, open the shell and type kill 1 then everything should work again.

cyan hare
#

okay should i reload it

#

right it here correct

frozen patio
cyan hare
#

it saying the same thing

olive osprey
#

Well, i just saw that youre coding a nuker bot...

#

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

frozen patio
#

We do not help with malicious bots

cyan hare
frozen patio
#

Still

final pumice
frozen patio
#

Against ToS

cyan hare
#

okay but if rate things every happen again how do u fix it

olive osprey
supple thorn
frozen patio
#

Repl is trash

cyan hare
olive osprey
#

I won't.

frozen patio
cyan hare
#

If that code every shown again how do you fix it

boreal ravine
frozen patio
boreal ravine
boreal ravine
frozen patio
#

If I have it right then why won't levels will not register

boreal ravine
#

I provided you with a solution...

frozen patio
boreal ravine
#

yes, like I said

the last setattr overwrites the old attribute

#

the solution is to just change the name of the attribute

velvet compass
cyan hare
#

i swear no one answering my question

boreal ravine
#

or you could create all of the tables inside one file

frozen patio
#

read rule 5

#

Would that lag the db

cloud dawn
boreal ravine
#

3 tables inside one file is fine

frozen patio
final pumice
slate swan
boreal ravine
slate swan
boreal ravine
#

the file would be big, if you wanna create different files for each table go ahead, just make sure you name the "db" something else

frozen patio
boreal ravine
#

yeah

frozen patio
#

Well the different databases did not work

#

So ig I will combine them

final pumice
#

Jonathan, does it?

frozen patio
#

Yes

final pumice
#

someone send me the docs

#

link to it pls

boreal ravine
unkempt canyonBOT
#

In order to work with the library and the Discord API in general, we must first create a Discord Bot account.

Creating a Bot account is a pretty straightforward process.

final pumice
#

Yes, tahnks

#

thanks*

final pumice
#

where is it

slate swan
#

why would there be a db attr?

final pumice
#

Jonathan said where was one

boreal ravine
final pumice
#

there*

slate swan
#

!bot-vars

unkempt canyonBOT
#

Python allows you to set custom attributes to most objects, like your bot! By storing things as attributes of the bot object, you can access them anywhere you access your bot. In the discord.py library, these custom attributes are commonly known as "bot variables" and can be a lifesaver if your bot is divided into many different files. An example on how to use custom attributes on your bot is shown below:

bot = commands.Bot(command_prefix="!")
# Set an attribute on our bot
bot.test = "I am accessible everywhere!"

@bot.command()
async def get(ctx: commands.Context):
    """A command to get the current value of `test`."""
    # Send what the test attribute is currently set to
    await ctx.send(ctx.bot.test)

@bot.command()
async def setval(ctx: commands.Context, *, new_text: str):
    """A command to set a new value of `test`."""
    # Here we change the attribute to what was specified in new_text
    bot.test = new_text

This all applies to cogs as well! You can set attributes to self as you wish.

Be sure not to overwrite attributes discord.py uses, like cogs or users. Name your attributes carefully!

final pumice
slate swan
#

it probably was a bot var

frozen patio
#

I combined the databases

#

worked like a charm

#

@boreal ravine Thank you so much.

cloud dawn
#

I also have a db var but it's not a bot var

frozen patio
#

I made my own cause yes

cloud dawn
#

😏

frozen patio
#

😏

slate swan
quaint epoch
paper sluice
#

pithink Intensifies

slate swan
vocal laurel
#

anyone here know hot to make a warning command witch includes warn, warnings and unwarn?

solar seal
#

Does anyone know how to fix this?

maiden fable
solar seal
#

1 sec

solar seal
#

@maiden fable did you just go offline?

#

bruh

#

why even offer to help

maiden fable
solar seal
umbral night
#

how would i make all pinned messages in a server go to a specific channel

#

is there something like

async def on_pin

or something

#

that i could use

solar seal
#

no

maiden fable
maiden fable
solar seal
#

i want to give people a role called muted

maiden fable
#

Remove ctx

solar seal
#

its just rude

maiden fable
#

Bruh, we also have irl stuff to do. No one can be online on discord all the time

solar seal
#

i didn't expect that but if people just go off in the middle of helping someone without saying a word it wastes peoples time

#

there is a difference between expecting common courtesy of not misleading people into thinking that they are getting help and having to stay on all the time

solar seal
maiden fable
solar seal
#

and then what?

maiden fable
#

Nothing

#

Wait

solar seal
#

and that doesn't work at all

maiden fable
#

Paste yr code here directly
Not the link

solar seal
#

ok

#

@client.tree.command(name="muted", description="mutes member")
@sec()
async def smute(inter: discord.Interaction, member: discord.Member):
Muted = discord.utils.get(guild.roles, name='Muted')
await member.add_roles(Muted)

maiden fable
#

Yea

#

inter.guild.roles

solar seal
#

nope

maiden fable
#

...

#

!d discord.Interaction.guild

unkempt canyonBOT
solar seal
#

yeah that doesn't show it at all

maiden fable
#

Eh wym

solar seal
#

i mean the section you linked doesn't reference the interactions with guilds to roles

maiden fable
#

Bro, u gotta do discord.utils.get(inter.guild.roles, name="Muted")

solar seal
#

that doesn't work

#

i literally already have that

maiden fable
#

Show

solar seal
#

@client.tree.command(name="muted", description="mutes member")
@sec()
async def smute(inter: discord.Interaction, member: discord.Member):
Muted = discord.utils.get(inter.guild.roles, name='Muted')
await member.add_roles(Muted)

maiden fable
#

That means there's no role with the name Muted

solar seal
#

no it doesn't

#

it throws up errors

slate swan
#

I had this code running and I don't really understand the error on this, can someone tell me?

WARNING:disnake.gateway:Shard ID None heartbeat blocked for more than 150 seconds.
Loop thread traceback (most recent call last):
  File "E:\Bots\Command\anarchic\source\bot.py", line 8724, in <module>
    bot.run(config.TOKEN)
  File "C:\Users\gcpla\AppData\Local\Programs\Python\Python39\lib\site-packages\disnake\client.py", line 846, in run
    loop.run_forever()
  File "C:\Users\gcpla\AppData\Local\Programs\Python\Python39\lib\asyncio\windows_events.py", line 316, in run_forever
    super().run_forever()
  File "C:\Users\gcpla\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 596, in run_forever
    self._run_once()
  File "C:\Users\gcpla\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 1890, in _run_once
    handle._run()
  File "C:\Users\gcpla\AppData\Local\Programs\Python\Python39\lib\asyncio\events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "C:\Users\gcpla\AppData\Local\Programs\Python\Python39\lib\site-packages\disnake\client.py", line 531, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\gcpla\AppData\Local\Programs\Python\Python39\lib\site-packages\disnake\ext\commands\interaction_bot_base.py", line 1340, in on_application_command
    await self.process_application_commands(interaction)
  File "C:\Users\gcpla\AppData\Local\Programs\Python\Python39\lib\site-packages\disnake\ext\commands\interaction_bot_base.py", line 1332, in process_application_commands
    await app_command.invoke(interaction)
  File "C:\Users\gcpla\AppData\Local\Programs\Python\Python39\lib\site-packages\disnake\ext\commands\slash_core.py", line 597, in invoke
    await call_param_func(self.callback, inter, self.cog, **kwargs)
  File "C:\Users\gcpla\AppData\Local\Programs\Python\Python39\lib\site-packages\disnake\ext\commands\params.py", line 778, in call_param_func
    return await maybe_coroutine(safe_call, function, **kwargs)
  File "C:\Users\gcpla\AppData\Local\Programs\Python\Python39\lib\site-packages\disnake\utils.py", line 561, in maybe_coroutine
    return await value
  File "E:\Bots\Command\anarchic\source\bot.py", line 2909, in sstart
    await _start(inter, True)
  File "E:\Bots\Command\anarchic\source\bot.py", line 3132, in _start
    await assignroles(var[ctx.guild.id]["setupz"], ctx.guild)
  File "E:\Bots\Command\anarchic\source\bot.py", line 6205, in assignroles
    hisrole = random.choice(var[ctx.id]["mafias"])
  File "C:\Users\gcpla\AppData\Local\Programs\Python\Python39\lib\random.py", line 344, in choice
maiden fable
#

How the heck do u expect the bot to get the role if it doesn't exist? 😐

maiden fable
#

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

solar seal
#

bruh thats not the problem i just told you that

maiden fable
#

@solar seal tell me... Do u have a role named Muted?

solar seal
#

yes

maiden fable
#

In that very guild?

solar seal
#

obviously

maiden fable
#

Then what's the error u r getting

solar seal
#

i am telling you it throws up errors in the code

maiden fable
#

I mean, share the error then bruh

solar seal
#

Argument of type "Role | None" cannot be assigned to parameter "roles" of type "Snowflake" in function "add_roles"
Type "Role | None" cannot be assigned to type "Snowflake"
"id" is not present

maiden fable
#

U can ignore that

#

Just a type error

#

Can u print Muted?

solar seal
#

ok thats just stupid that it shows an error but is fine

#

thx for the help

spice adder
#

Is there a way to replace characters in a string from a regex with blank spaces?

maiden fable
solar seal
#

ah

spice adder
#

I mean how would you go about replacing it

unkempt canyonBOT
#

str.strip([chars])```
Return a copy of the string with the leading and trailing characters removed. The *chars* argument is a string specifying the set of characters to be removed. If omitted or `None`, the *chars* argument defaults to removing whitespace. The *chars* argument is not a prefix or suffix; rather, all combinations of its values are stripped:

```py
>>> '   spacious   '.strip()
'spacious'
>>> 'www.example.com'.strip('cmowz.')
'example'
```  The outermost leading and trailing *chars* argument values are stripped from the string. Characters are removed from the leading end until reaching a string character that is not contained in the set of characters in *chars*. A similar action takes place on the trailing end. For example:
maiden fable
#

This removes the spaces

spice adder
#

Does it work with regex?

maiden fable
#

Wym by that?

slate swan
#

it works with any kind of string

spice adder
#

So essentially, the bot we use to ban adds the user-username to the audit log reason for some reason

#

So I'm wanting to replace anything in the reason matching the regex (?i)(.*#\d{4}): with ""

umbral night
#

how could i make all pinned messages get sent to a certain channel

#

all pinned messages in every channel*

spice adder
#

I.e. it would replace abcd#1234: with ""

silver wolf
solar seal
silver wolf
maiden fable
#

if Muted is not None:
. . .

solar seal
#

fair

silver wolf
#

that or type ignore (if thats what ur talking about)

maiden fable
#

Eh, I would advice against type ignores

slate swan
#

yo

spice adder
#

Cut-down code: ```py
banreason = await guild.fetch_ban(user)
newreason = re.sub('(?i)(.*#\d{4}):', ' ', (str banreason.reason))
[...]
banembed.add_field(name="📄 Reason:", value=f"{newreason}", inline=True)

Error: ```re
Ignoring exception in on_member_ban
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 94, in on_member_ban
    newreason = re.sub('(?i)(.*#\d{4}):',  ' ', banreason.reason)
NameError: name 're' is not defined
slate swan
#

import re when?

paper sluice
#

(str banreason.reason)pithinkpithinkpithink

spice adder
slate swan
#

yea that too

slate swan
spice adder
#

Hmm

#

I am way to tired, I pressed ctrl+z too much at some point and got rid of import redawoqLKM{oaw;kdjonbb

keen talon
#

Anyone there pithink

supple thorn
rotund leaf
keen talon
slate swan
#

what did i do? i only added one command

maiden fable
feral lichen
#

you cant have a command named a function unless use use an alias im quite sure

maiden fable
#

Wym

#

The default name of a command is the name of the function

slate swan
feral lichen
#

my bad, like this ```py
bot.command(aliases = ['8ball'])

#

@maiden fable

maiden fable
#

Ah those are command aliases

feral lichen
#

wrong person pinged lmao 💀

oblique adder
#

how to get all members id from a guild ?

slate swan
#
list = []
for members in ctx.guild.members:
    list.append(members.id)
#

@oblique adder

slate swan
#

a list comprehension is faster

#

( m.id for m in Guild.members)

paper sluice
#

[*map(lambda x: x.id, ctx.guild.members)]

#

meh this is longer, sad

slate swan
#

but even more faster

#

;-;

paper sluice
solar seal
#

anyone know how to make a clear command for slash commands on discord.py?

paper sluice
#

what do you want to clear?

solar seal
#

messages

#

like /clear num

#

i just don't understand how to input the integer for it

paper sluice
#

just int(str)

solar seal
#

that doesn't work

paper sluice
#

whats wrong?

solar seal
#

let me send the trash i have

slate swan
#

show code

solar seal
#

@client.tree.command(name="clear", description="clears messages")
@sec()
async def sclear(inter: discord.Interaction):
await inter.channel.purge(limit=)

slate swan
#

h

#

wtf

paper sluice
#

await inter.channel.purge(limit=) just why

solar seal
#

wdym?

paper sluice
#

just take the limit sclear(inter: discord.Interaction): here

#

then convert to int

solar seal
#

i would have done that if i knew how

#

literally i can do everything fine except anything to do with slash commands

paper sluice
#
async def sclear(inter: discord.Interaction, limit):
    limit = int(limit)
    ...
solar seal
#

well actually i am getting better but still

#

how do i annotate limit?

paper sluice
#

limit: int, it doesn't really do anything if u expecting it to

#

its just for the reader to know that it limit should be int

solar seal
#

its just saying i have to

paper sluice
#

who its?

solar seal
#

the error

#

yeah it still doesn't give me a place to input a number

paper sluice
#

you need to sync the tree to update slash commands

solar seal
#

1 sec

#

ok it updated

#

thx

#

i put 1 and it deleted way more than 1

cold sonnet
#

why don't you typehint to int

#

@paper sluice

paper sluice
cold sonnet
#

it does though

#

and it has an effect on slash commands

paper sluice
cold sonnet
#

if it can't convert to int, it raises an error

#

else, limit's gonna be an int

paper sluice
#

i didnt know that, cool

obsidian ledge
#

why do i keep getting

raise HTTPException(r, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In embed.author.icon_url: Scheme "2cbf391d2820b66f610327bced0af098" is not supported. Scheme must be one of ('http', 'https').
slate swan
#

Is there anyway to get the transcripts from a discord channel in this format?

["Person#0000: Hello, this is a message", "AnotherPerson#0000: Hello, this is another message"]```
sullen pewter
#

How to make the bot use slash commands without entering guild id

placid skiff
sullen pewter
#

Will it take 1 hour once

#

Or every time it joins a server

placid skiff
#

that before they would be available globally it will take up to 1 hour

sullen pewter
#

How to do it

placid skiff
slate swan
#

ok

#

I think the problem describes itself but how can i fix it?

sullen pewter
placid skiff
placid skiff
#

that doesn't mean that everytime it takes 1 hour

#

it can take like 5 minutes or it can take 1 hour

sullen pewter
paper sluice
slate swan
#

TEXT FILE - JSON DATA
user_data = '{ "userid":"user1", "cash":"100"}'
user_data = '{ "userid":"user2", "cash":"100"}'
user_data = '{ "userid":"user3", "cash":"100"}'
user_data = '{ "userid":"user4", "cash":"100"}'
user_data = '{ "userid":"user5", "cash":"100"}'
user_data = '{ "userid":"user6", "cash":"100"}'

Code:
`import json

with open("userdata.txt", 'w') as f:
f.write(message.content + '\n')
json_load = (json.loads(json_data))
print(json_load['python'])`

how to make python add 50 cash to userid, user 5? by finding and replacing the value in txt file? sorry im new to this , pls help me thxs :/

placid skiff
#

json is used to represents javascript object in text files, not as storage method

slate swan
#

for my discord bot*

inland beacon
#

how to self bot in cog?

slate swan
#

"/

#

?

#

what can i use for storing user data?

inland beacon
slate swan
inland beacon
#

MongoDB, Deta, MySQL, PostgreSQL, Cassandra, MariaDB, SQLite3

inland beacon
slate swan
#

oh

supple thorn
inland beacon
#

yes..

supple thorn
#

💀

keen talon
#

👀

supple thorn
unkempt canyonBOT
#

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

inland beacon
#

its not against tos..

slate swan
#

it is

supple thorn
#

Do you also want me to go through discord ToS

inland beacon
#
class fun(Cog):
  def __init__(self, bot):
    self bot = bot
``` syntax error??
keen talon
slate swan
#

uh

keen talon
#

😆 😆 😆

placid skiff
# slate swan then how do i make it for a currency system?

when you load json object in python you'll get a dict of the data inside

{
  "name":"bob"
  "languages":["English", "French"]
}
import json
with open('path_to_file/your.json', 'r') as f:
  data = json.load(f)

print(data)

Output: {'name': 'bob', 'languages': ['English', 'French']}

inland beacon
#

thank you guys

keen talon
slate swan
#

:nice:

supple thorn
slate swan
#

ok

placid skiff
keen talon
supple thorn
#

It was either about instance variables or literal self botting

slate swan
#

ok

paper sluice
#

ok

cold sonnet
slate swan
#
async def giveaway(self , ctx:commands.Context, x , channel:disnake.TextChannel, time1 , time2 , winlimit , * , title ):
#

my givewaway function lol

cold sonnet
#

why do you have so many spaces? 😔

slate swan
#

it looks nice

cold sonnet
#

it looks inhumane

slate swan
#

..

#
    async def giveaway(self,ctx:commands.Context,x ,channel:disnake.TextChannel,time1,time2,winlimit,*,title):
#

fine

cold sonnet
#
async def giveaway(self, ctx : commands.Context, x, channel : disnake.Textchannel...):
paper sluice
#

i will help you out

    async def giveaway(
        self, 
        ctx: commands.Context,
        x, 
        channel: disnake.TextChannel, 
        time1,
        time2,
        winlimit,
        *,
        title
    ):
slate swan
#
    async def giveaway(self, ctx:commands.Context, x , channel:disnake.TextChannel, time1, time2, winlimit, *, title):
#

nice

cold sonnet
slate swan
#

..

slate swan
#

uh

cold sonnet
#

but it looks much better

#

🥳

slate swan
#
async def giveaway(self, ctx:commands.Context, x, channel:disnake.TextChannel, time1, time2, winlimit, *, title):
#

fine now

thick token
#

How to create music in python without ffmpeg?

thick token
slate swan
#
async def giveaway(self, ctx:commands.Context, x, channel: disnake.TextChannel, time1, time2, winlimit, *, title):
cold sonnet
slate swan
#

now dont dare

slate swan
#

f

#
 async def giveaway(self, ctx :commands.Context, x, channel: disnake.TextChannel, time1, time2, winlimit, *, title):
cold sonnet
#

but I'm not a pep8 master so

#

I suppose price

#

is x

slate swan
#

x is st or stop time 1 is 1 , 2 , 3 and tim2 is hour week sec week mmonth

paper sluice
#

st?

slate swan
#

if x in ["Start","start","st"]:

paper sluice
#
 async def giveaway(self, ctx :commands.Context, x, channel: disnake.TextChannel, time: int, unit: str, winlimit, *, title):```
name it better
slate swan
#

hm?

cold sonnet
slate swan
slate swan
paper sluice
thick token
#

How to create music in python without ffmpeg?

slate swan
#

didnt understand

cold sonnet
#

why black

dull terrace
#

oh god i just had flashbacks to when i tried to send a countdown message to about 100 servers for a giveaway

#

and at the end it selected a random winner for every server instead of one for all eyesintensify

cold sonnet
#

:thumbsup_tone5:

placid skiff
#

lol i've discovered that the VPN of the client which i'm workin for blocks my website

slate swan
#

`import sqlite3 as lite

con = lite.connect('user_data.db')

with con:

cur = con.cursor()

cur.execute("CREATE TABLE user_data(UserID TEXT, Cash INT)")
cur.execute("INSERT INTO user_data VALUES('12031909',10)")
cur.execute("INSERT INTO user_data VALUES('51511111',10)")
cur.execute("INSERT INTO user_data VALUES('8841214',10)")`

if user id 12031909 is in table change the specific user cash by +1. how to do this?

umbral night
#

how would i go on from here?

# mute command
@bot.command()
@commands.has_permissions(manage_roles = True)
async def mute(ctx):
#

i'm trying to make the command give a person a role

slate swan
paper sluice
placid skiff
#

first you get the value you want then you do your things and add it again D_D

dull terrace
#

and fetchone

placid skiff
#

can't tell you how i made custom method for my sql

dull terrace
#

if it returns none then do your operation

slate swan
#

any sample code?

placid skiff
dull terrace
#

cur.execute("SELECT FROM user_data WHERE id = ?", (id,))

#

butt = cur.fetchone()

#

if butt is None:

slate swan
#

thx

#

::D_D:

#

:D_D:

sullen pewter
#

How can I fix this

dull terrace
#

easiest way is to delete it all

placid skiff
#

bro you can't sync commands manually

dull terrace
sullen pewter
eternal apex
#

i'm trying to make my bot send buttons but it says ImportError: cannot import name 'InteractionType' from 'discord_components

from discord_components import DiscordComponents, Button, ButtonStyle, InteractionType
@bot.command()
async def button(ctx):
  await ctx.send("Press Button",
                 components = [
    Button(style=ButtonStyle.blue,
           label="CLICK Me!")
    ]
  )
  rest = await bot.wait_for("button_click")
  await rest.respond(type=InteractionEventType.ChannelMessagewithSource,
                     content="Clicked!")```
slate swan
dull terrace
placid skiff
slate swan
sullen pewter
#
@client.tree.command()```
sullen pewter
#

But then I won't be able to sync

dull terrace
sullen pewter
#

Cuz I need to sync to use slash commands

dull terrace
#

best place i found to learn

slate swan
placid skiff
#

Client has NO tree method D_D
What is so hard? D_D

dull terrace
#

BlvckTvrsier.tree

vast gale
#

have you ever used vscode? @placid skiff

#

tldr tree exists on their client

#

and sync exists as well

placid skiff
#

Bruh D_D

vast gale
#

an attribute is white if the type checker doesn't know what it is in vscode

#

they've probably subclassed client and added tree to it

placid skiff
#

lol i'm not really sure about it, show your client instance @sullen pewter

slate swan
#

how to set a cooldown for message.content.lower?
2 second response cooldown for each user of the bot?

dull terrace
placid skiff
#

CliEnT = commands.BoT lol

slate swan
#

ik this question is stupid, but i want to set cooldown*

dull terrace
#

you understand message.content.lower just turns everything lowercase right

placid skiff
#

Did you subclass bot?

sullen pewter
placid skiff
#

doubt it too you are using commands.Bot

#

so i'm right, there is no method client.tree in your code D_D

dull terrace
#

might be inbuilt way depending on the library you're using

slate swan
sullen pewter
#

A variable or a command

placid skiff
#

the only way there is a client.tree is because you wrote client.tree = something in your code

sullen pewter
#

Wdym by method

placid skiff
#

omg

sullen pewter
#

No

placid skiff
#

i'm out D_D

sullen pewter
#

I have this and it works fine

dull terrace
sullen pewter
slate swan
dull terrace
#

I would heavily suggest that you go through some python tutorials online or something @slate swan or you're going to struggle

placid skiff
#

before getting to dpy you should know python and OOP concepts

slate swan
#

i would love to learn

slate swan
dull terrace
#

i picked up my python in bits and pieces through googling so i don't know any good teaching resources