#discord-bots

1 messages · Page 908 of 1

unkempt canyonBOT
#

json.dump(obj, fp, *, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, cls=None, indent=None, separators=None, default=None, sort_keys=False, **kw)```
Serialize *obj* as a JSON formatted stream to *fp* (a `.write()`-supporting [file-like object](https://docs.python.org/3/glossary.html#term-file-like-object)) using this [conversion table](https://docs.python.org/3/library/json.html#py-to-json-table).

If *skipkeys* is true (default: `False`), then dict keys that are not of a basic type ([`str`](https://docs.python.org/3/library/stdtypes.html#str "str"), [`int`](https://docs.python.org/3/library/functions.html#int "int"), [`float`](https://docs.python.org/3/library/functions.html#float "float"), [`bool`](https://docs.python.org/3/library/functions.html#bool "bool"), `None`) will be skipped instead of raising a [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "TypeError").

The [`json`](https://docs.python.org/3/library/json.html#module-json "json: Encode and decode the JSON format.") module always produces [`str`](https://docs.python.org/3/library/stdtypes.html#str "str") objects, not [`bytes`](https://docs.python.org/3/library/stdtypes.html#bytes "bytes") objects. Therefore, `fp.write()` must support [`str`](https://docs.python.org/3/library/stdtypes.html#str "str") input.

If *ensure\_ascii* is true (the default), the output is guaranteed to have all incoming non-ASCII characters escaped. If *ensure\_ascii* is false, these characters will be output as-is.
slate swan
#

ok

#

it works

#

before

#
An exception has occurred while executing command `mine`:
Traceback (most recent call last):
  File "C:\Users\turne.DESKTOP-8B1DN4C\AppData\Local\Programs\Python\Python39\lib\site-packages\discord_slash\client.py", line 1353, in invoke_command
    await func.invoke(ctx, **args)
  File "C:\Users\turne.DESKTOP-8B1DN4C\AppData\Local\Programs\Python\Python39\lib\site-packages\discord_slash\model.py", line 210, in invoke
    return await self.func(*args, **kwargs)
  File "C:\Users\turne.DESKTOP-8B1DN4C\OneDrive\Desktop\Dogeminer\main.py", line 94, in mine
    with open('storage.json', 'w') as f:
TypeError: 'BaseCommandObject' object is not callable
#

im trying to dump this{'683041051740602402': {'doge': 0.079, 'bank': 0, 'mining_cooldown': 7.3641541, 'balance_cooldown': 0, 'hack_cooldown': 0, 'hack': 0, 'timesmined': 1, 'pickaxes': 1, 'fourtunes': 1, 'beta': True, 'timeline': 0, 'rocksmined': 0, 'moonc': 0, 'marsc': 0, 'jupiterc': 0, 'earthc': 0, 'titanc': 0}}

supple thorn
#

Okay

supple thorn
#

Also what's your code

slate swan
#
        if chance_for_rock <= chance_radius:
            users[str(ctx.author.id)]["rocksmined"] += 1
            rocksmined += 1
            

        embed = discord.Embed(description=f"{ctx.author.mention} Mined!",color=0xf8fd08)
        embed.set_thumbnail(url="https://upload.wikimedia.org/wikipedia/en/d/d0/Dogecoin_Logo.png")
        embed.add_field(name="Amount :", value=f"{money}Ɖ" , inline=True)
        print(users)
        with open('storage.json', 'w') as f:
            json.dump(users, f)
        if chance_for_rock <= chance_radius:
            embed.add_field(name=f"Dude, you mined a rock! You now have {rocksmined}:rock:", value="⠀", inline=False)
            
        await ctx.send(embed=embed)
    else:
        embed = discord.Embed(description=f"Oops, cooldown! you need to wait {round(cooldown - time.perf_counter(), 2)} Seconds! WOW")
        embed.set_thumbnail(url="https://upload.wikimedia.org/wikipedia/en/d/d0/Dogecoin_Logo.png")
        await ctx.send(embed=embed)
upbeat otter
#

huhhhh, discord bot maker

maiden fable
sage otter
#

You can even download it on your phone smilebutcryinside

maiden fable
#

Indeed, but idk if its the same developer who made it for pc

upbeat otter
sage otter
maiden fable
sage otter
#

I did too. That’s why I know it’s trash

maiden fable
upbeat otter
#

but what does the application charge for.....

sage otter
#

It doesn’t

upbeat otter
#

ads?

maiden fable
#

It is paid iirc

sage otter
#

The hosting is paid.

maiden fable
#

(At least the PC version is)

upbeat otter
slate swan
#

why are u talking here????

sage otter
# upbeat otter ads?

the one on mobile they make money off of ads. They have like a hosting system setup. The more adds you watch the more hours you get of free hosting.

maiden fable
maiden fable
upbeat otter
slate swan
#

yes

maiden fable
pliant gulch
maiden fable
upbeat otter
maiden fable
sage otter
supple thorn
#

Jesus

sage otter
#

That’s definitely not euro

maiden fable
slate swan
#

from audioop import mul
from pydoc import describe
import discord
import random
import os
import math
from discord_slash import SlashCommand, ButtonStyle
from discord.ext import commands
from discord_slash.utils.manage_components import create_button, create_actionrow
from discord_slash.model import ButtonStyle
import json
import time

upbeat otter
maiden fable
#

Yea, its INR tho

supple thorn
pliant gulch
#

Rupee?

supple thorn
#

It looked the same so i guessed

maiden fable
maiden fable
pliant gulch
#

So it’s like around 3 USD

upbeat otter
#

but okay, cool kid

supple thorn
# maiden fable 👀

You could pay someone to actually code a discord bot for you that's actually good

supple thorn
maiden fable
supple thorn
#

Nevermind then lmao

maiden fable
#

Games/Apps on Steam are costlier in USA

supple thorn
#

I thought they be charging it like how Apple does

maiden fable
supple thorn
#

I'm not saying they do anything wrong

upbeat otter
#

its like 5.8 USD 😔

#

my bad if im wrong

supple thorn
#

I'm just saying their prices are high

maiden fable
maiden fable
#

😔 And they don't even have voice receive or support for sending requests to other APIs

upbeat otter
gaunt ice
maiden fable
supple thorn
#

Don't mind me but

maiden fable
supple thorn
#

I always wanted to do this

gaunt ice
#

ey

supple thorn
#

!ot

unkempt canyonBOT
slate swan
#
@slash.slash(name="mine", description="This Mines For some good doge WOW")

async def minerock(ctx):
maiden fable
upbeat otter
#

Imagine paying 6 dollars instead of carl 😔
Totally not sponsored to upvote Carl

supple thorn
#

Hire humans

upbeat otter
supple thorn
#

^preferably adults

maiden fable
upbeat otter
maiden fable
slate swan
#
@slash.slash(name="profile", description="Profile with stats! WOW")
async def profile(ctx, user: discord.User = None):
#

that works

supple thorn
#

🗿

maiden fable
#

Anyways I'mma just go away before mina comes here and bothers @unkempt canyon to give us a warn

upbeat otter
#

anyways, I'm breaking the rule of not using discord, so bye, ||and yes, ot||

supple thorn
#

I saw that

terse blade
#

how to make this "f'{ctx.author.mention} slaps {user.mention}!'"
work in an embed

maiden fable
slate swan
#

its this!!!
with open('storage.json', 'w') as f:
json.dump(users, f)

placid skiff
#

uhm what is going on here?

supple thorn
maiden fable
terse blade
supple thorn
placid skiff
upbeat otter
terse blade
#
        description="f'{ctx.author.mention} slaps {user.mention}!'")```
upbeat otter
placid skiff
#

Hahahaha dunno why but i wrote brake

upbeat otter
inner epoch
#

Any1 has term of service format for discord bots?

upbeat otter
supple thorn
#

You forgot to tell them to import it

placid skiff
upbeat otter
#

I mean, you could say that in a polite way but okay

upbeat otter
supple thorn
#

Bad

unkempt canyonBOT
#

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

f'{x} {y}'
supple thorn
#

Spray

placid skiff
maiden fable
#

No thanks

slate swan
#

yes

upbeat otter
placid skiff
#

conc is shit compared to the beauty of f string

maiden fable
#

Nvm

unkempt canyonBOT
slate swan
#

shit, ot2 is cursed today

placid skiff
#

🙄

maiden fable
#

You do know we all read that message, right? @slate swan

placid skiff
#

Oh now you are a bad person

#

why in the hell i can't write today

maiden fable
#

LMAO

supple thorn
supple thorn
#

Don't worry none of us can

#

Leye

placid skiff
#

lol

supple thorn
#

I'm using that as a placeholder of lies

slate swan
maiden fable
#

Stop it

placid skiff
#

you are abusing the ot

maiden fable
#

Yes, it is annoying asf now

placid skiff
#

from now until new order you are forbidden from using the ot word

terse blade
#

how do I make main be able to use the commands from the commands folder

gaunt ice
#

addcog

slate swan
#

Hey Guys, I need help with whitelisting certain roles for my discord bot and blacklisting certain roles from doing commands

#

If someone could help that would be great

honest vessel
#

!d discord.ext.commands.has_role

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")
honest vessel
#

@slate swan ^

supple thorn
honest vessel
#

well all that is not whitelisted are blacklisted????

supple thorn
#

Might aswell just do a custom check yourself

terse blade
#

my commands now dont work when i use cogs

gaunt ice
#

wha

#

show code

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied mute to @terse blade until <t:1647434581:f> (9 minutes and 59 seconds) (reason: newlines rule: sent 11 consecutive newlines in 10s).

low latch
#

!unmute 820370330203062294

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: pardoned infraction mute for @terse blade.

low latch
#

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

low latch
#

@terse blade please use this for big pieces of code

terse blade
jolly basalt
#

How to know when a bot has stopped playing music in a vc

terse blade
#

when u dont hear music anymore?

jolly basalt
#

yes

terse blade
#

When u dont hear music anymore

jolly basalt
slate swan
#

uh

#

wait

terse blade
#

!d discord.VoiceClient.is_playing

unkempt canyonBOT
jolly basalt
slate swan
#

or using something in the after kwarg of VoiceChannel.play

terse blade
slate swan
terse blade
#

commands

slate swan
#

show the cog file bruh 🥲

jolly basalt
terse blade
slate swan
#

you put the command outside if the cog

#

indent the help command

#

why exactly are you defining bot again?

gaunt ice
#

lmfao

terse blade
#

im autistic

slate swan
#

prolly not

terse blade
slate swan
#

the load_extension you're doing in the other file

terse blade
#

it said to on the example 😭

slate swan
#

will put bot to your setup function

slate swan
terse blade
#

so i can get rid of it?

slate swan
#

yes

#

you only need it in your main file

#

and indent the help command as I said

terse blade
#

def setup(bot):
bot.add_cog(HelpCog(bot))
delete this?

slate swan
#

load_extension in your main file will call this setup function

#

you need this

terse blade
#

Heh

slate swan
#
    #searches file
    setup(bot) ```
#

basically what dpy does for u

spring flax
#

you can do this right? ```py
@commands.group(aliases=something, invoke_without_command=True)
async def something():
pass

@ssomething.command(aliases=something_else)
async def anotherthing():
pass

slate swan
#

you don't need this, dpy does it for u

terse blade
slate swan
terse blade
slate swan
#

so does it work with the setup function?

terse blade
#

U lost me 🤣

slate swan
#

no

terse blade
#

It works with the indents

slate swan
#

we're still in it

#

so it works

terse blade
#

Ye

slate swan
#

should've stopped right there

slate swan
terse blade
#

made sense

drowsy thunder
#

How to change rich presence in nextcord

#

@slate swan

slate swan
drowsy thunder
slate swan
#

ofc nvm, I'm dumb

flat solstice
#

How do I make a nested group command in ex.commands. I have this role_group role command func with a subccomand func of info_legacy ```py
@commands.group(name = "role", invoke_without_command = True, case_insensitive = True, aliases = ["rank"])
async def role_group(self, ctx):
await parent(ctx)

@role_group.command(name="info", description=info_description, usage = "<role>", aliases = ["whatis", "ri"])
async def info_legacy(self, ctx, role: Role = None):
    await Roles(self).info_func(ctx, role)```but I want to make a subcommand func for `info_legacy` so would it be ```py

@role_group.group()
async def info_legacy():

@info_legacy.command()
async def info_sub():```

slate swan
# drowsy thunder Yes

either define it in the bot constructor (use the activity kwarg) or use the change_presence method on the Bot object

drowsy thunder
slate swan
# drowsy thunder Idk how to use change_presence
# Setting `Playing ` status
await bot.change_presence(activity=discord.Game(name="a game"))
# Setting `Streaming ` status
await bot.change_presence(activity=discord.Streaming(name="My Stream", url=my_twitch_url))
# Setting `Listening ` status
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name="a song"))
# Setting `Watching ` status
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="a movie"))
drowsy thunder
#

It works for Nextcord?

oblique adder
#

How do I make a handler for BotMissingPermissions in try except /
//nextcord

slate swan
slate swan
#

you need to use the check and the error command handler

drowsy thunder
#

@slate swan Any idea to use streaming status without twitch url

drowsy thunder
#

So it must stay what?

slate swan
#

huh?

drowsy thunder
#

It should be my_twitch_url?

slate swan
#

!d discord.Streaming

unkempt canyonBOT
#

class discord.Streaming(*, name, url, **extra)```
A slimmed down version of [`Activity`](https://discordpy.readthedocs.io/en/master/api.html#discord.Activity "discord.Activity") that represents a Discord streaming status.

This is typically displayed via **Streaming** on the official Discord client.

x == y Checks if two streams are equal.

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

hash(x) Returns the stream’s hash.

str(x) Returns the stream’s name.
slate swan
#

yes, url is optional

#

or any url works

drowsy thunder
#

So the url should be url= and nothing after that?

#

I'll use MrBeast6000 LMAOO

slate swan
drowsy thunder
#

Ok got it

oblique adder
drowsy thunder
#

Btw I am making a powerful security bot so if any of you wanna help then you can dm me

oblique adder
drowsy thunder
slate swan
oblique adder
oblique adder
drowsy thunder
gaunt ice
#

they get over like in a month

oblique adder
# drowsy thunder No,profile rule no 3

No noisy unicode characters (for example z̯̯͡a̧͎̺l̡͓̫g̹̲o̡̼̘) or rapidly flashing avatars.

does my name look like z̯̯͡a̧͎̺l̡͓̫g̹̲o̡̼̘ ? if not kindly don't talk.

drowsy thunder
oblique adder
#

then don't

drowsy thunder
#

Keep it simple

#

Thats what the rule means

oblique adder
#

you can reply to the message with mention on.

drowsy thunder
gaunt ice
#

it's fine ryan

slate swan
# oblique adder yes
@commands.Cog.listener("on_command_error")
async def uwu_command_error(self, ctx, exc):
  if isinstance(exc, commands.BotMissingPermissions):
    '''whatever you wanna do here'''

@commands.command()
@commands.bot_has_permissions(any_discord.Permissions=True) #this check will trigger the error handler
async def whatever_command(self, ctx):
  whatever```\
gaunt ice
#

chill

drowsy thunder
#

Ok,bye
Ima get back to coding and have some music beatmusic

drowsy thunder
slate swan
#

inside your command.

slate swan
#

well that was common sense but uhh

drowsy thunder
slate swan
#

Btw thats an event?

#

*listener

slate swan
quick gust
#

they've specified the event in the parenthesis

slate swan
#

The name of the event Is inside listener decorator

quick gust
drowsy thunder
#

@slate swan can you tell how to make changing status? It needs intents or not?

slate swan
slate swan
slate swan
#

!d discord.Client.event

unkempt canyonBOT
#

@event```
A decorator that registers an event to listen to.

You can find more info about the events on the [documentation below](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events).

The events must be a [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine "(in Python v3.10)"), if not, [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.10)") is raised.

Example

```py
@client.event
async def on_ready():
    print('Ready!')
slate swan
#

!d discord.ext.tasks.loop

unkempt canyonBOT
#

discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True, loop=...)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
slate swan
drowsy thunder
slate swan
#

!d discord.ext.commands.Bot.listen

unkempt canyonBOT
#

@listen(name=None)```
A decorator that registers another function as an external event listener. Basically this allows you to listen to multiple events from different places e.g. such as [`on_ready()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_ready "discord.on_ready")

The functions being listened to must be a [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine "(in Python v3.10)").

Example...
quick gust
slate swan
drowsy thunder
slate swan
# drowsy thunder Code?

`def pop_random_line6():
"""picks a random line from a file, then deletes the line"""
with open("Month Spoofer Key.txt", "r") as file:
lines = file.readlines()

chosen_index = random.randrange(0, len(lines))
chosen_line = lines[chosen_index]

with open("Month Spoofer Key.txt", "w") as file:
    del lines[chosen_index]
    file.writelines(lines)

return chosen_line

@client.command()
async def MonthSpoofer(ctx):
roles = [role.name for role in ctx.message.author.roles]
if 'Owner' in roles:
line = await pop_random_line6()
await ctx.message.reply(line)
else:
await ctx.message.reply("You don't have the permission to execute the command!")
await asyncio.sleep(5)
await ctx.send("INSTRUCTIONS WILL BE TYPED HERE")`

#

There can be only one event, but multiple listeners

drowsy thunder
slate swan
quick gust
#

ur function isn't async but you're using await inside it...?

drowsy thunder
honest vessel
quick gust
#

wait nvm i read it wrong

drowsy thunder
slate swan
slate swan
# drowsy thunder Example?
@nextcord.ext.tasks.loop(minutes=5)
async def uwu_status():
  list_of_status = []
  await bot.change_presence(activity=discord.Game(name=random.choice(list_of_status)))

uwu_status.start()
slate swan
drowsy thunder
# slate swan

There it is,the error is in line 94
Try to determine it

slate swan
#

Remove that await

slate swan
#

only async functions ( coroutines ) need to be awaited

#

Thanks for the help @slate swan & @drowsy thunder

drowsy thunder
drowsy thunder
slate swan
drowsy thunder
slate swan
manic wing
#

!d discord.ext.tasks.loop

unkempt canyonBOT
#

discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True, loop=...)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
drowsy thunder
manic wing
#

you will get ratelimited

slate swan
drowsy thunder
#

How much should it be then
30 seconds?

slate swan
#

keep it 45 seconds at least

drowsy thunder
slate swan
#

It won't lag

#

But you will get ratelimited.

drowsy thunder
slate swan
flat solstice
#

Whats the command to eval code?

slim ibex
#

!eval

unkempt canyonBOT
#
Command Help

!eval [code]
Can also use: e

*Run Python code and get the results.

This command supports multiple lines of code, including code wrapped inside a formatted code block. Code can be re-evaluated by editing the original message within 10 seconds and clicking the reaction that subsequently appears.

We've done our best to make this sandboxed, but do let us know if you manage to find an issue with it!*

slate swan
#

!src e

unkempt canyonBOT
#
Command: eval

Run Python code and get the results.

Source Code
slate swan
#

overkill

#

30sec would be fine

craggy cloak
#
/home/container/main.py:43: RuntimeWarning: coroutine 'BotBase.load_extension' was never awaited
  client.load_extension(f"cogs.{file[:-3]}")
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

Lol why this?

#

ping if you can help me

quick gust
#

src link for how python bot does this?

slate swan
quick gust
#

I need the source link for how @unkempt canyon does that

quick gust
#

github repo lines -> discord

slim ibex
#

!src src

quick gust
#

what?

unkempt canyonBOT
#
Command: source

Display information and a GitHub link to the source code of a command, tag, or cog.

Source Code
slate swan
#

he means display the code

quick gust
#

No..? it reads the lines from the link and sends it on discord

slate swan
#

smh you guys

quick gust
final iron
#

No he means how it pulls the code from the repo and posts it in chat

slate swan
#

im not sure infernum but you should browse around the repo

quick gust
#

exactly!

slate swan
#

!src

unkempt canyonBOT
quick gust
#

i tried

#

for the past 10 mins lol, too complex for me

slate swan
#

ill try to find it hold on

quick gust
#

alr sure take your time

unkempt canyonBOT
#

bot/exts/info/code_snippets.py line 244

async def on_message(self, message: discord.Message) -> None:```
craggy cloak
quick gust
#

ah ty

#

caeden to the rescue

manic wing
#

always

craggy cloak
slate swan
#

Hi, I got an error saying that client has no attribute named command and I don't know what I did wrong but isn't @client.command supposed to work? this is my code ```python
import discord
from discord.ext import commands

#server_id = "922146486840590367"

def read_token():
with open("token.txt", "r") as f:
lines = f.readlines()
return lines[0].strip()

token = read_token()
bot = commands.Bot(command_prefix='?')
client = discord.Client()

@client.command()
async def ping(ctx):
await ctx.send("working")

client.run(token)

#

client should be an instance of the Bot class

slate swan
cold sonnet
#

with oop

cold sonnet
#

wtf is that emoji

slate swan
#

lol

slate swan
slate swan
cold sonnet
#

every bot is a client

slate swan
#

OHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH

slate swan
#

hence the error

#

so I replace the decorator with bot.command()

#

bro

cold sonnet
#

quick learner

gaunt ice
#

hi.

cold sonnet
slate swan
#

one more question...

gaunt ice
#

hi?

slate swan
#

when I run the command in the server it doesnt say anything

cold sonnet
gaunt ice
#

hi

slate swan
cold sonnet
#

ew

gaunt ice
slate swan
#

with the fixed code

slate swan
gaunt ice
#

show code.

cold sonnet
#

you run the client, not the bot

slate swan
#
import discord
from discord.ext import commands

#server_id = "922146486840590367"

def read_token():
    with open("token.txt", "r") as f:
        lines = f.readlines()
        return lines[0].strip()

token = read_token()
bot = commands.Bot(command_prefix='?')
client = discord.Client()

@bot.command()
async def ping(ctx):
    await ctx.send("working")

client.run(token)```
cold sonnet
#

guys the fuck, he has

slate swan
#

2124_MikeSullyFaceSwap wipe out the client var

gaunt ice
slate swan
#

why have client and the bot classSajunaBruh

gaunt ice
#

I CANT UNSEE IT NOW

slate swan
#

im sorry lol

slate swan
#

I am a disgrace

gaunt ice
slate swan
#

smhSajunaBruh

slate swan
gaunt ice
#

discord light mode is for boomers

cold sonnet
slate swan
gaunt ice
#

but u aint one uwh

cold sonnet
#

xenoren stop

slate swan
gaunt ice
#

okok

cold sonnet
#

xenoren you need to stop

gaunt ice
#

ok

slate swan
#

!ot kek

unkempt canyonBOT
cold sonnet
#

nerd

slate swan
#

!it 02think

cold sonnet
#

!t ?

slate swan
#

mhm

gaunt ice
#

@slate swan is the bot online

#

IM JK

slate swan
quick gust
#

dies

gaunt ice
slate swan
#

lmao

#

alright then imma use it for a day too and see kek

gaunt ice
#

no

#

dont ......

cold sonnet
#

I'm in

slate swan
#

yall nerds use high contrast hmmcat

gaunt ice
#

we are loosing Ashley mayday

cold sonnet
#

god

gaunt ice
#

ah

cold sonnet
#

it looks disgusting

gaunt ice
#

lmfao

quick gust
#

!ot

gaunt ice
#

ok sry

cold sonnet
#

you'll never guess who used it

quick gust
#

No, I used an invisible character \

cold sonnet
#

stop cap

quick gust
#

try it and see

#

\!ot

slate swan
#

the cool down is per channel its probably on cooldown

quick gust
#

lol it's not

cold sonnet
#

lol it is

quick gust
#

uhh ok whatever u guys say

slate swan
#

they should have the time be given tbh maybe in the footer

#

!

#

oooo

terse blade
#

how do i put something in the bots about me

quick gust
#

through the developer portal

terse blade
#

How do I make its status streaming

#

I try it but it dosent work

gaunt ice
#

u need to change status

#

from dnd or anything to streaming

terse blade
#

I did but it dosen't change it

gaunt ice
#

frig I'm dumb

cold sonnet
#

imagine not knowing the full path to every literal class

gaunt ice
#

....

cold sonnet
#

!d discord.ext.commands.Bot.status

unkempt canyonBOT
#

property status```
[`Status`](https://discordpy.readthedocs.io/en/master/api.html#discord.Status "discord.Status"): The status being used upon logging on to Discord.
cold sonnet
#

and attr

pallid meadow
#

Any way to flags like “-user @pallid meadow” instead of “user: @pallid meadow” for example

#

I am using disnake btw but the implementation is identical to all of the other forks

placid skiff
#

wdym?

placid skiff
cold sonnet
#

no

#

it's written so the python bot can use it

placid skiff
#

ok you are joking

cold sonnet
#

so we can ignore people by invoking a command with the right argument

pallid meadow
hazy oxide
#

does anyone know how to make bot delete their message in nextcord slash command?

slate swan
#

you can use the delete method on the Message object returned when you send it, idk if that will work

hazy oxide
#

I use .delete() and it doesn't work

#

await message.delete()

honest vessel
#

u have permissions?

slate swan
slate swan
honest vessel
#

how i know it was bots own message

slate swan
#

it's a message sent by a webhook

#

all of the interaction responses are webhooks

#

what

gaunt ice
#

wait what am I doing

#

I'm sry I'm kinda depressed now

maiden fable
hazy oxide
#

NoneType object has no attribute delete

slate swan
#

interaction.response.any_method returns None.

slate swan
slate swan
sage otter
#

wait did you mean attr or method?

slate swan
sage otter
#

I thought you meant something tbh

drowsy thunder
#

@slate swan can ya help

slate swan
#

help with?

drowsy thunder
#

So

#

I made a auto mod in which if a user swears it says youre not allowed to swear so,is there a way to delete the response from the bot after 5 seconds? @slate swan

slate swan
#

.send() takes a delete_after kwarg, use it

#

!d discord.abc.Messageable.send

unkempt canyonBOT
#
await send(content=None, *, tts=False, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sends a message to the destination with the content given.

The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.

To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.

To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
drowsy thunder
#

Cuz I use await ctx.channel.send

honest vessel
#

delete_after=10 (deletes after 10 seconds)

gaunt ice
drowsy thunder
#

Ohk thx

vocal plover
sly hamlet
#
  File "C:\Users\culan\OneDrive\Desktop\echo slash\cogs\fun.py", line 20, in <module>
    class fun(commands.Cog):
  File "C:\Users\culan\OneDrive\Desktop\echo slash\cogs\fun.py", line 69, in fun
    async def search(self, interaction: discord.Interaction, query):
  File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\commands.py", line 991, in decorator
    return Command(
  File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\commands.py", line 383, in __init__
    self._params: Dict[str, CommandParameter] = _extract_parameters_from_callback(callback, callback.__globals__)
  File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\commands.py", line 275, in _extract_parameters_from_callback
    raise TypeError(f'annotation for {parameter.name} must be given')
TypeError: annotation for query must be given
>>> ``` ```py
         @app_commands.command(name='poll',
                       description="Creates a poll.")
    async def poll(self, interaction: discord.Interaction, args):
            if not len(args) > 0 :
                None
            else :
                questionSondage = "".join(args)
                dictEmbed = {
                    "title": ":bar_chart: Poll",
                    "description": \
                                    f"""
                    
                            {questionSondage}
                        
                        """
                } 
                sondageMessage = await interaction.response.send_message(embed = discord.Embed.from_dict(dictEmbed))
                await sondageMessage.add_reaction("\U0001f44d")
            
                await sondageMessage.add_reaction("\U0001f44e")```how can i fix this i have 4 command giveing this error
placid skiff
#

uhm i'm not sure that we can help you, youtube policy is very aggressive

final iron
#

Don't see anything wrong with it

slate swan
placid skiff
#

untill he has something related to a music bot or something that breaks some laws

sly hamlet
placid skiff
#

lol you have 3 more commands related to this error

sly hamlet
placid skiff
#

could be a workaround to this rule

slate swan
#

I am trying to change my nickname with this bot but it says that it doesnt have perms but I gave it a role that has a admin and everything this is the error ```Ignoring exception in command change_nick:
Traceback (most recent call last):
File "C:\Users\joelj\anaconda3\envs\undbot\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:/Users/joelj/PycharmProjects/UndBot/BotMain.py", line 41, in change_nick

await member.edit(nick=arg2)

File "C:\Users\joelj\anaconda3\envs\undbot\lib\site-packages\discord\member.py", line 681, in edit
await http.edit_member(guild_id, self.id, reason=reason, **payload)
File "C:\Users\joelj\anaconda3\envs\undbot\lib\site-packages\discord\http.py", line 248, in request
raise Forbidden(r, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions

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

Traceback (most recent call last):
File "C:\Users\joelj\anaconda3\envs\undbot\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\joelj\anaconda3\envs\undbot\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\joelj\anaconda3\envs\undbot\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions``` this is my code

#
import discord
from discord.ext import commands
import time

#server_id = "922146486840590367"

def read_token():
    with open("token.txt", "r") as f:
        lines = f.readlines()
        return lines[0].strip()

token = read_token()
bot = commands.Bot(command_prefix='?')
time_seconds = 0

@bot.command()
async def nuke(ctx, arg1="", arg2=30):

    if arg2 > 60:
        await ctx.send("Lets keep it under 60 seconds for my sake :)")

    else:

        if "@" in arg1:
            await ctx.send(f"""A Nuke has been Launched Towards {arg1} and will destroy *everything they love* in {arg2} seconds""")
            time_seconds = arg2
            start = time.time()
            time.clock()
            elapsed = 1
            while elapsed < (time_seconds):
                elapsed = time.time() - (start+-1)
                time.sleep(1)
            await ctx.send(f"""{arg1} has been reduced to *atoms*, **double kill**, *annihilation*, *extinction*, ***rampage*** """)

        else:
            await ctx.send("Invalid Usage: ?nuke <@user> <seconds>")

@bot.command()
async def change_nick(ctx, member: discord.Member, arg2):
    if arg2 != "":
        await member.edit(nick=arg2)
    else:
        await ctx.send("Invalid Usage: /change_nick <@user> <nickname>")


bot.run(token)
final iron
slate swan
terse blade
#

how to make a level system uwu

slate swan
terse blade
slate swan
#

sigh

final iron
terse blade
slate swan
#

and I am owner

terse blade
#

it dosent work 🤣

slate swan
#

great

final iron
terse blade
#

invite me then try it

slate swan
final iron
#

Get an alt in the server

slate swan
#

ok thx u

terse blade
slate swan
#

no thx

terse blade
#

so rude

final iron
terse blade
final iron
#

Okay

terse blade
#

is it cause i cogged it?

slate swan
#

cogged it?

terse blade
#

cog

slate swan
#

what about it

terse blade
#

is it cause i put it on a cog

slate swan
#

probably not

terse blade
#

i mean the code is 3 years old

slate swan
#

well did you load the cog?

terse blade
#

it should've i got no errors

slate swan
#

How do I host my discord bot 24/7

terse blade
#

but when i send a message it just dosent show in db

slate swan
slate swan
terse blade
slate swan
slate swan
slate swan
slate swan
slate swan
terse blade
#

it works fine for my commands

crystal cliff
#

How do I send api data from console to a json file?

slate swan
#

theres so much other things to talk about as well lmao

crystal cliff
terse blade
#

so i have to put that all in main?

slate swan
final iron
terse blade
slate swan
#

!d discord.ext.commands.Cog.listener

unkempt canyonBOT
#

classmethod listener(name=...)```
A decorator that marks a function as a listener.

This is the cog equivalent of [`Bot.listen()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.listen "discord.ext.commands.Bot.listen").
terse blade
#

so if i change event to listen?

slate swan
#

?

final iron
#

You need to change a lot of things

terse blade
#

breh

slate swan
#

hes speaking the truth lol

terse blade
#

like wut

slate swan
#

want me to point it all out?!?!

terse blade
#

im so confused its incredible

slate swan
#

just look at the tutorial i sent

outer parcel
#

Hi everyone im making a music bot but i keep on running into this error

final iron
#

🗿

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

this is my code

unkempt canyonBOT
#

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

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

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

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

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

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

hey guys

outer parcel
#

The error is no attribute called FFmpeg

cosmic agate
#

my bot not working

terse blade
outer parcel
#
raise ClientException(f"{executable} was not found.") from Nonediscord.errors.ClientException: ffmpeg was not found.

error

final iron
cosmic agate
#

someone help pls

outer parcel
#

Ah 😦

#

Where can i find help

cosmic agate
#

@outer parcel youre making music command?

final iron
cosmic agate
manic wing
upbeat otter
cosmic agate
#

guys my bot not working like it should

spring flax
#

can someone help guide me on how to make a paginator with buttons and each page has 5 fields and values depending on what I select from my DB
if that makes sense

cosmic agate
spring flax
#

that's pretty vague

cosmic agate
#

guys my bot not working like it shows that it its online but no command work

sullen shoal
slate swan
cosmic agate
manic wing
#

it would make no difference

cosmic agate
terse blade
slate swan
terse blade
#

its ment for commands not listeners

sullen shoal
sullen shoal
cosmic agate
slate swan
sullen shoal
terse blade
#

why wont my cog work

sullen shoal
slate swan
terse blade
sullen shoal
# cosmic agate

you dont need 4 different on_message global events for that.

cosmic agate
#

hmm

maiden fable
# cosmic agate

Congrats, you totally won the award for the BEST code ever!

cosmic agate
spring flax
#
task: <Task pending name='disnake: app_command_preparation' coro=<InteractionBotBase._prepare_application_commands() running at C:\Users\tenuk\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\disnake\ext\commands\interaction_bot_base.py:849> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x0000022E7F8BDF70>()]>>```
What's this?
manic wing
cosmic agate
#

im noob man

manic wing
#

you can only have one event but multiple listens

left crater
#

you can use .lower() so you don't have to make a bunch of if statements

terse blade
cosmic agate
#

@sullen shoal can you help me here?

left crater
sullen shoal
cosmic agate
slate swan
unkempt canyonBOT
#

classmethod listener(name=...)```
A decorator that marks a function as a listener.

This is the cog equivalent of [`Bot.listen()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.listen "discord.ext.commands.Bot.listen").
terse blade
#

cause the tutorial sent does cmds

slate swan
sullen shoal
cosmic agate
#

ohok

terse blade
#

so replae all bot.events with bot.listen

slate swan
#

Y’all would uptime robot work for hosting a bot

slate swan
slate swan
terse blade
slate swan
#

well it does if you actually read it

slate swan
#

i know its long an all but atleast read it

sullen shoal
slate swan
#

because you can doesnt mean you should

sullen shoal
sullen shoal
terse blade
#
    async def on_member_join(member):
        with open('users.json', 'r') as f:
            user = json.load(f)

        await update_data(users, member)```
something like this?
final iron
#

Yesn't

sullen shoal
#

your code is blocking and the library is asynchronous as it should be

terse blade
#

hehhh

sullen shoal
#

and please dont use json as a database, its not meant to be used for that

terse blade
#

it was a tut from 3 years ago ._.

sullen shoal
#

youtube discord bot tutorials from top youtubers are trash and I wish those get deleted as soon as possible

terse blade
#

Then what am i ment to do 😭

slate swan
#

What database should I use for my economy system?

sullen shoal
terse blade
#

whats a good DB then

final iron
#

Sqlite is an option

slate swan
#

Is sqllite easy to learn or does it take time?

sullen shoal
#

you just gotta need the programmer-like thinking skills of an average programmer to learn the intermediate stuff in 2-3 days or so

#

otherwise, it might take some more days

final iron
#

I learnt the basics in a couple of days

terse blade
#

why is coding difficult

manic wing
#

its not

final iron
sullen shoal
#

i mean coding also includes html, if thats not easy then idk what is

terse blade
final iron
manic wing
#

learning an actual language is much harder

terse blade
final iron
#

Well actually it depends

#

If your native language was English and you're trying to learn Chinese I would say it's harder

slate swan
#

my command prefix is -p how can i make it so even if its more than one whitespace it will still run the command
Example of what im trying to say:
-p help

sullen shoal
#

when you gotta open their grammer book then you would know the pain of learning an irl language

final iron
#

But if your native language was English and you're trying to learn a language like French it's easier

manic wing
#

coding is logic whereas learning a language requires you to learn some 40k words, how to conjugate, pronouns, all sorts of shit

final iron
#

Coding is technically logic but it's much harder to learn in practice

sullen shoal
#

its hard in the beginning, but, after you understand the concept, you just need to know some english keywords and some bit of syntax that shouldnt take much time, the other work is just knowing different functions and stuff of the built-in libs of that programming language, i would call it vocabulary of that programming language or some shit

slate swan
terse blade
#
Traceback (most recent call last):
  File "C:\Users\hustl\AppData\Local\Programs\Python\Python39\lib\site-packages\disnake\client.py", line 531, in _run_event
    await coro(*args, **kwargs)
  File "D:\Discord BOT\main.py", line 46, in on_message
    await update_Data(users, message.author)
UnboundLocalError: local variable 'update_Data' referenced before assignment```
help
final iron
#

Code?

terse blade
slate swan
#

Is it possible to cancel the command used before, with another command?

sullen shoal
terse blade
# final iron Code?
async def on_member_join(member):
    with open('users.json', 'r') as f:
        user = json.load(f)

    await update_data(users, member)

    with open('users.json', 'w') as f:
        json.dump(users, f)```
slate swan
sullen shoal
slate swan
sullen shoal
terse blade
#

someone help..

sullen shoal
quaint epoch
#

how do i do dis?

slate swan
final iron
#

!e

def my_func():
    my_inner_func()

    def my_inner_func():
        print("a")

my_func()
unkempt canyonBOT
#

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

001 | Traceback (most recent call last):
002 |   File "<string>", line 7, in <module>
003 |   File "<string>", line 2, in my_func
004 | UnboundLocalError: local variable 'my_inner_func' referenced before assignment
terse blade
#

someone help!

final iron
#

@terse blade see the issue?

terse blade
#

no i dont

final iron
#

Try looking at it hard

manic wing
#

the python thread goes top to bottom

quaint epoch
#

wow, all of the accounts here really are just self-botted to copy and send every error they find

sullen shoal
# slate swan i think about 36 seconds in total to finish

set an attribute to your Bot instance
ctx.bot.canceled = False

instead of sending them yourself, make a list of strings containing each message. then iterate through the list and on each iteration, check if bot.canceled is True, if it is, then return else send the current element

hollow badger
#

Be more respectful, please

velvet compass
manic wing
#

he's stacked on evidence

quaint epoch
#

!e py def some_function(x): print(double(x)) def double(val): return val * 2

unkempt canyonBOT
#

@quaint epoch :warning: Your eval job has completed with return code 0.

[No output]
quaint epoch
#

oh i forgot to run it lol

#

!e py def some_function(x): print(double(x)) def double(val): return val * 2 some_function()

unkempt canyonBOT
#

@quaint epoch :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 5, in <module>
003 | TypeError: some_function() missing 1 required positional argument: 'x'
quaint epoch
#

wow maybe i'm a bot

#

!e py def some_function(x): print(double(x)) def double(val): return val * 2 some_function(1)

unkempt canyonBOT
#

@quaint epoch :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 5, in <module>
003 |   File "<string>", line 2, in some_function
004 | UnboundLocalError: local variable 'double' referenced before assignment
final iron
#

?

quaint epoch
manic wing
#

#bot-commands

quaint epoch
quaint epoch
slate swan
terse blade
#

I don't know why its reading top to bottom tho

quaint epoch
#

you can't change that

terse blade
#

so whats the error

quaint epoch
#

your function update_data is probably further down the code, so you have to move it up to the top

final iron
#

Just like my example showed

quaint epoch
#

anyone ping me if you know how to do this -

final iron
#

It's a timestamp

manic wing
unkempt canyonBOT
#

disnake.utils.format_dt(dt, /, style='f')```
A helper function to format a [`datetime.datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "(in Python v3.10)"), [`int`](https://docs.python.org/3/library/functions.html#int "(in Python v3.10)") or [`float`](https://docs.python.org/3/library/functions.html#float "(in Python v3.10)") for presentation within Discord.

This allows for a locale-independent way of presenting data using Discord specific Markdown...
final iron
#

<t:17282727>
<t:17282727>

quaint epoch
terse blade
manic wing
#

you might want to consider learning basic python

terse blade
#

i put it before everything and it still happens

final iron
#

!e

def my_func():
    my_inner_func()

    def my_inner_func():
        print("a")

my_func()
unkempt canyonBOT
#

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

001 | Traceback (most recent call last):
002 |   File "<string>", line 7, in <module>
003 |   File "<string>", line 2, in my_func
004 | UnboundLocalError: local variable 'my_inner_func' referenced before assignment
final iron
#

Doesn't work

#

But

terse blade
#

wait

final iron
#

!e

def my_func():

    def my_inner_func():
        print("a")
    
    my_inner_func()

my_func()
unkempt canyonBOT
#

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

a
manic wing
#

this isnt really helping him

final iron
#

🤷‍♂️

terse blade
#

it was the wrong error

final iron
#

What else can I do

terse blade
#
async def on_message(message):
    with open('users.json', 'r') as f:
        user = json.load(f)

    await update_Data(users, message.author)
    await add_experience(users, message.author, arg)
    await level_up(users, message.author, message.channel)

    with open('users.json', 'w') as f:
            json.dump(users, f)


    async def update_Data(users, user):
        if not user.id in users:
            users[user.id] = {}
            users[user.id]['experience'] = 0
            users[user.id]['level'] = 1

    async def add_experience(users, user, exp):
        users[user.id]['experience'] + exp

    async def level_up(users, user, channel):
        experience = users[user.id]['experience']
        lvl_start = users[user.id]['level']
        lvl_end = int(experience ** (1/4))

        if lvl_start < lvl_end:
            await client.send_message(channel, '{} has leveled up to {}' .format(user.mention, lvl_end))
            users[user.id]['level'] = lvl_end```
#

Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\hustl\AppData\Local\Programs\Python\Python39\lib\site-packages\disnake\client.py", line 531, in _run_event
await coro(*args, **kwargs)
File "D:\Discord BOT\main.py", line 44, in on_message
await update_Data(users, message.author)
UnboundLocalError: local variable 'update_Data' referenced before assignment

sullen shoal
#

damn

honest vessel
#

read ->
UnboundLocalError: local variable 'update_Data' referenced before assignment

final iron
honest vessel
#

google the error too, read learn something?

#

basic python

terse blade
#

ive never encountered this error

honest vessel
#

" referenced before assignment" should tell u enough

terse blade
final iron
terse blade
#

im so lost 🤦‍♂️

honest vessel
#

cause you dont try learn python and just take copy pasta codes

#

i even search now on await update_Data in this discord, i can see plenty have same script.

terse blade
#

i dont copy and pasta but ok

honest vessel
#

ok u sure?

terse blade
#

?

honest vessel
#

same code and there is plenty of them

terse blade
#

it isnt but ok

slate swan
#

Is he Calling a function before the instance of where it is written?

honest vessel
#

so you just named examctly same variables and all? wow thats a huge miracle

terse blade
#

ikr!!

rugged steeple
# honest vessel

Why not make use of a guard statement instead?

async def on_message(msg):
   if msg.author.bot:
      return
   
    with open("users.json") as f:
       users = json.load(f)
    ...

Edit: @wicked lily

honest vessel
#

But all have given u answer n helped u

slate swan
#

👆

honest vessel
#

@rugged steepleits a print of searched on this server... to show that @terse blade sais he didnt copy pasta but its exactly same code.

#

they all prob asked same questions too lol

terse blade
#

taking python so seriously 💀

rugged steeple
terse blade
#

stop pissing urself man its hella funny

honest vessel
slate swan
#
Traceback (most recent call last):
  File "C:\Users\turne.DESKTOP-8B1DN4C\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\tree.py", line 998, in call
    await command._invoke_with_namespace(interaction, namespace)
  File "C:\Users\turne.DESKTOP-8B1DN4C\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\commands.py", line 481, in _invoke_with_namespace
    raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'profile' raised an exception: AttributeError: 'Interaction' object has no attribute 'send'```
#

anyone know whats happened

terse blade
#

myixu farted

honest vessel
#

@terse bladeand you know poeple has answered u lol.

terse blade
#

didnt ask

slate swan
#

Why question then

#

😂

terse blade
#

didnt

slate swan
#

K

slate swan
terse blade
#

#bot-commands

honest vessel
#

@final iron comeone bro error said .send() not exists for interaction 😛

#

!d disnake.Interaction

unkempt canyonBOT
#

class disnake.Interaction```
A base class representing a user-initiated Discord interaction.

An interaction happens when a user performs an action that the client needs to be notified of. Current examples are application commands and components.

New in version 2.0.
restive urchin
#

what is this disnake library?

sullen shoal
restive urchin
#

:o

honest vessel
#

!d disnake.Interaction.response

unkempt canyonBOT
#

Returns an object responsible for handling responding to the interaction.

A response can only be done once. If secondary messages need to be sent, consider using followup instead.

honest vessel
#

@slate swan ^

sullen shoal
restive urchin
#

If it comes highly recommended i'll have to swap over.

#

Oh it has slash commands? Discord doesn't have those yet.

#

I mean the discord library

honest vessel
#

!d disnake.Interaction.send

unkempt canyonBOT
#

await send(content=None, *, embed=..., embeds=..., file=..., files=..., allowed_mentions=..., view=..., components=..., tts=False, ephemeral=False, delete_after=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sends a message using either [`response.send_message`](https://docs.disnake.dev/en/latest/api.html#disnake.InteractionResponse.send_message "disnake.InteractionResponse.send_message") or [`followup.send`](https://docs.disnake.dev/en/latest/api.html#disnake.Webhook.send "disnake.Webhook.send").

If the interaction hasn’t been responded to yet, this method will call [`response.send_message`](https://docs.disnake.dev/en/latest/api.html#disnake.InteractionResponse.send_message "disnake.InteractionResponse.send_message"). Otherwise, it will call [`followup.send`](https://docs.disnake.dev/en/latest/api.html#disnake.Webhook.send "disnake.Webhook.send").

Note

This method does not return a [`Message`](https://docs.disnake.dev/en/latest/api.html#disnake.Message "disnake.Message") object. If you need a message object, use [`original_message()`](https://docs.disnake.dev/en/latest/api.html#disnake.Interaction.original_message "disnake.Interaction.original_message") to fetch it, or use [`followup.send`](https://docs.disnake.dev/en/latest/api.html#disnake.Webhook.send "disnake.Webhook.send") directly instead of this method if you’re sending a followup message.
final iron
restive urchin
#

Cool, I'll look into it.

timid wagon
#

Then again, you should have a look at the syntax first

terse blade
#
    json.dump(users, f)
NameError: name 'users' is not defined

What should I define a user as?

honest vessel
timid wagon
#

dpy's implementation is complicated, and not final (it's not on stable)

sullen shoal
honest vessel
#

its a variable - but not defined... but maybe it should be a string like "users.json" but what ever basic python

#

@manic wingaint this kinda too much? huh

slate swan
#

Where do i put my description on the command on slash command

manic wing
#

just ignore him

timid wagon
honest vessel
terse blade
#
Traceback (most recent call last):
  File "C:\Users\hustl\AppData\Local\Programs\Python\Python39\lib\site-packages\disnake\client.py", line 531, in _run_event
    await coro(*args, **kwargs)
  File "D:\Discord BOT\main.py", line 49, in on_message
    json.dump(users, f)
  File "C:\Users\hustl\AppData\Local\Programs\Python\Python39\lib\json\__init__.py", line 179, in dump
    for chunk in iterable:
  File "C:\Users\hustl\AppData\Local\Programs\Python\Python39\lib\json\encoder.py", line 438, in _iterencode
    o = _default(o)
  File "C:\Users\hustl\AppData\Local\Programs\Python\Python39\lib\json\encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type module is not JSON serializable```
What does this mean
honest vessel
#

it means json is broken

#

file should contain {}

manic wing
slate swan
#

@terse bladecode?

timid wagon
#

In disnake,

@bot.slash_command(description="This is the description")
async def command():
    ...

# OR

@bot.slash_command()
async def command():
    """This is the description using docstrings."""```
terse blade
terse blade
slate swan
#

@terse bladesend code

#

cant do much with 1 line

sullen shoal
final iron
honest vessel
slate swan
#

@final ironwheres that

terse blade
final iron
honest vessel
manic wing
slate swan
#

@terse bladesend the code

final iron
#

!d discord.app_commands.CommandTree.command

unkempt canyonBOT
terse blade
final iron
honest vessel
#

@terse bladeam gonna block u - even got advised to ignore u.

terse blade
restive urchin
#

I see it's pretty active in here so I claimed #help-chocolate for what I was typing up for here

candid pilot
#
async def give(ctx, a: int, member: discord.Member=None):
    users = await chung_data()
    user = member or ctx.author
    wallet_amt = users[str(user.id)]["Wallet"]
    users[str(member.id)]["Wallet"] += a
    users[str(ctx.author.id)]["Wallet"] -= a
    with open("chungbank.json", "w") as f:
            json.dump(users, f)

    embed = discord.Embed(title = f"given {a} leancoins")
    embed.add_field(name = f"{user} now has", value = f"{wallet_amt} leancoins")
    await ctx.send(embed = embed)``` heres my code so basically when i give coins to another person i can still give a million even if i have zero and it showes that i now have -1 million, i want the command to not be useable for users who have no coins
sick birch
ebon island
#

What's the best way to handle listening for events in a particular voice channel say joins/leaves etc?

slate swan
#

@final ironWhere at tho

#
@tree.command()
async def mine(interaction: discord.Interaction):
final iron
slate swan
#

@tree.command()???

final iron
#

That is the decorator

slate swan
#

C:\Users\turne.DESKTOP-8B1DN4C\OneDrive\Desktop\Dogeminer>C:/Users/turne.DESKTOP-8B1DN4C/AppData/Local/Programs/Python/Python39/python.exe c:/Users/turne.DESKTOP-8B1DN4C/OneDrive/Desktop/Dogeminer/main.py
Traceback (most recent call last):
File "c:\Users\turne.DESKTOP-8B1DN4C\OneDrive\Desktop\Dogeminer\main.py", line 35, in <module>
@tree.command(describe = "HI")
TypeError: command() got an unexpected keyword argument 'describe'

#

@tree.command(describe = "HI")

final iron
#

There's no describe kwarg

quick gust
#

maybe you're looking for description instead?

final iron
slate swan
#

hey, i am making a ?roll command but it dont work because my link "are not valid argument" ! Can someone help me ?

import discord
import os
import random
from discord.utils import get
from discord.ext import commands
default_intents = discord.Intents.default()
default_intents.members = True

bot = commands.Bot(command_prefix="?")

@bot.command(name="roll")
async def rating(ctx):
    variable_list = [
        'https://ibb.co/XZpqkTq',
        'https://ibb.co/XtsCbGg',
        'https://ibb.co/vX5SbWB',
        'https://ibb.co/9ZRKDq0',
        'https://ibb.co/n7nMj7F',
        'https://ibb.co/k9K96fQ',
    ]

    embed = discord.Embed(
        colour=0xc81f9f,
        title="Dé",
        description=(random.choice(variable_list)),
        file=discord.File((random.choice(variable_list)))
        
    )
    embed.set_footer(text=f"{ctx.message.guild.name}")
    await ctx.send(embed=embed)

bot.run("mytoken")
sullen shoal
slate swan
sullen shoal
slate swan
#

image ^^'

sullen shoal
#

!d discord.Embed.set_image

unkempt canyonBOT
#

set_image(*, url)```
Sets the image for the embed content.

This function returns the class instance to allow for fluent-style chaining.
slate swan
#

in description= ?

sullen shoal
#

embed is an instance of discord.Embed

#

embed.set_image(...)

#

both of them will newly choose a random item from the list. You have to store it as a variable then pass it to both of these

honest vessel
sullen shoal
#

theres not need of file kwarg if you use set_image btw

honest vessel
#

^

honest vessel
#

yeah set_image would do what u want smoothest simplest

#

@sullen shoalsmart thinking 😉

sullen shoal
#

😉

slate swan
#

😳

#
Ignoring exception in command tree:
Traceback (most recent call last):
  File "C:\Users\turne.DESKTOP-8B1DN4C\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\tree.py", line 875, in wrapper
    await self.call(interaction)
  File "C:\Users\turne.DESKTOP-8B1DN4C\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\tree.py", line 955, in call
    raise CommandNotFound(name, parents)
discord.app_commands.errors.CommandNotFound: Application command 'mine' not found
PRO```
 why did this happen after i added a description
foggy merlin
#

How do invite tracking bots work if there is a 1000 invite limit (meaning only 1000 members can be tracked)

slate swan
#

1 perm invite

vocal plover
#

It's not one invite per user, it looks at all the invite join counts before and after a member joins, sees which has changed and reports it

slate swan
#
C:\Users\turne.DESKTOP-8B1DN4C\OneDrive\Desktop\Dogeminer>C:/Users/turne.DESKTOP-8B1DN4C/AppData/Local/Programs/Python/Python39/python.exe c:/Users/turne.DESKTOP-8B1DN4C/OneDrive/Desktop/Dogeminer/main.py
Ignoring exception in command tree:
Traceback (most recent call last):
  File "C:\Users\turne.DESKTOP-8B1DN4C\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\tree.py", line 875, in wrapper
    await self.call(interaction)
  File "C:\Users\turne.DESKTOP-8B1DN4C\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\tree.py", line 955, in call
    raise CommandNotFound(name, parents)
discord.app_commands.errors.CommandNotFound: Application command 'mine' not found


#

i changed description#=#

foggy merlin
slate swan
#

no

vocal plover
#

No

#

You can see all of the invites and who created them, after a member joins you see which invite increased its join count, then you get the person who created the invite and that's who invited the member

candid pilot
sick birch
#

I doubt that

candid pilot
#

i havent had any problems yet

sick birch
#

Yet but needless overcomplication

sullen shoal
#

using db is actually easier than shitty (in this case) json

sick birch
#

But to solve your original issue you'd want to check if the user's current amount is greater than or equal to the amount they want to give

sick birch
foggy merlin
sullen shoal
#

yep

foggy merlin
#

meaning <= 1000 users who created that invite

vocal plover
#

huh?

foggy merlin
#

each member can create their own invite

#

which is then associated with them, since they've created it

sick birch
#

Yes..?

foggy merlin
#

if someone joins using that invite, then you can see that they have joined using that invite

#

and can get the user who created that invite and do whatever

sick birch
#

Well you'd have to write your own logic but yes

foggy merlin
#

maybe i am failing to understand. If you have 1 perm invite link, how can that be associated to multiple users?

#

only 1 person has created that perm invite

vocal plover
#

It's not associated with multiple users

sick birch
#

Stop thinking of invites as associated with users that will help you understand

vocal plover
#

its associated with whoever made it