#discord-bots

1 messages Β· Page 1051 of 1

hexed pagoda
#

yess i tried smt like that ,i will yours now thanks

hollow zealot
#

like what?

neat field
#

in order to get data from different discord objects , like members, guilds channel etc

#

you need to access them by having intents

#

basically like the perm in order to access those data

hexed pagoda
#

client = discord.Client(intents= discord.Intents.default()) voila

neat field
#

yep

hexed pagoda
#

no type errors anymore thankuu

neat field
#

yw

hexed pagoda
#

capital I what i needed i guess XD

neat field
#

lol

hexed pagoda
#

:DDD

hollow zealot
neat field
#

no worries

#

these kinda the basics

hollow zealot
neat field
#

cool

hollow zealot
#

im kinda late learner

neat field
#

no such thing as late

#

o

hollow zealot
#

i start to learning rn and i learn after a few months of not doing code at all

neat field
#

lol

hollow zealot
#

that also happens when im learning lua

neat field
#

lol

hollow zealot
#

also can i add u?

neat field
#

erm sure ig idk

#

u can add me if ur not gonn abother my dms tho

hollow zealot
granite parcel
#

how to get user by id

ebon island
#

When already playing a song in disnake, is it possible to play a sound clip over top either by pausing the current or better yet without pausing the already playing song?

quaint scaffold
unkempt canyonBOT
#

get_user(id, /)```
Returns a user with the given ID.

Changed in version 2.0: `id` parameter is now positional-only.
maiden fable
ebon island
#

Can you resume the previously playing sound once the new sound is finished?

zenith mural
#
import discord
from discord.ext import commands
import bs4
from googlesearch import search

TOKEN = ""

bot = commands.Bot(command_prefix="ds!")


@bot.event
async def on_ready():
    print("We have logged in as {0.user}".format(bot))

@bot.command()
async def search(ctx,*, query):
    await ctx.channel.send(f"Answer:")

    async with ctx.typing():
        for ans in search(query, tld="co.in", num=10, stop=10, pause=2):
            await ctx.send(f"\n:point_right: {ans}")
bot.run(TOKEN)
``` Hey! can someone help me with this? it isnt working
ebon island
#

I think you will need to give more information about what is happening because even though that code is short it is not good practice to expect others to parse through your entire code base without even telling them what the error is or exception you encountered

maiden fable
slate swan
#
@client.command()
async def roles(ctx):
  select = Select(options=[
      discord.SelectOption(label="Bloody Red", emoji=":dotred:", description="Red Color")
  ])
  view = View()
  view.add_item(select)
  await ctx.send("Choose a color!", view=view)
  async def my_callback2(interaction):
    if select.values[0] == "Fun Commands":
      member = ctx.message.author
      role = get(member.guild.roles, name="˗ˏˋ꒰ πŸ’ κ’±")
      await interaction.response.send_message(content="Gave You <@&93628772078177487>", ephemeral=True)

how can i add the role to the user who clicked on the option

slate swan
shrewd harbor
#

help

slate swan
#

response*

#

yes

slate swan
#

The id_ is inputed as a string, and then you try to fetch as if it were an integer. Do: ```py
async def reroll(ctx, channel: discord.TextChannel, id_: int):

slate swan
#

nothing in console

#
@client.command()
async def roles(ctx):
  select = Select(options=[
      discord.SelectOption(label="Bloody Red", emoji=":dotred:", description="Red Color")
  ])
  view = View()
  view.add_item(select)
  await ctx.send("Choose a color!", view=view)
  async def my_callback2(interaction):
    if select.values[0] == "Fun Commands":
      member = ctx.message.author
      role = get(member.guild.roles, name="˗ˏˋ꒰ πŸ’ κ’±")
      await interaction.user.add_roles(member, role)
      await interaction.user.send_message("Gave you <@&936287720781774870>", ephemeral=True)
      select.callback = my_callback2

slate swan
#

oh wait
lemme do it

slate swan
ebon island
slate swan
hollow zealot
# neat field erm sure ig idk

I promise this would be my last question for the day but how do I check players if have a specific role and how to give the role?

slate swan
#

or above the callback

slate swan
neat field
hollow zealot
neat field
#

u mean create a var

hollow zealot
neat field
#

this part of dpy packages

#

everything u need is already there

hollow zealot
#

what is lambda? is it a var?

cloud dawn
#

!d lambda

unkempt canyonBOT
#

An anonymous inline function consisting of a single expression
which is evaluated when the function is called. The syntax to create
a lambda function is lambda [parameters]: expression

neat field
#

try async for entry in role.guild.audit_logs(limit=1, action=discord.AuditLogAction.role_create):

neat field
hollow zealot
neat field
slate swan
#

how come i didnt see select.values[0] == "Fun commands!":

hollow zealot
maiden fable
neat field
#
async for entry in role.guild.audit_logs(limit=1, action=discord.AuditLogAction.role_create):
    
    channel = guild.get_channel(976462750438014976)
    logs = logs[0]
    if logs.target == role:
        await channel.send(f'{logs.user} Created Role.')```
#

traceback?

#

ye

slate swan
hollow zealot
neat field
#

show full code of the cmd

#

then i will be able to help

#

oh i see the eror

hollow zealot
#
@client.event
async def on_message(message):
  if message.content == "!checkrole":
    role = discord.utils.find(lambda r: r.name == 'Member', ctx.message.guild.roles)
    if role in user.roles:
      await message.channel.send("Yay!")```
neat field
#
async for entry in role.guild.audit_logs(limit=1, action=discord.AuditLogAction.role_create):
    logs = entry
channel = guild.get_channel(976462750438014976)
logs = logs[0]
if logs.target == role:
        await channel.send(f'{logs.user} Created Role.')```
#

this the code

#

obv fix the identation

hollow zealot
neat field
#

@slate swan try that ^^

hollow zealot
#

oh fu- ur arent talking to me srry

neat field
#
async def on_message(message):
  if message.content == "!checkrole":
    role = discord.utils.find(lambda r: r.id == role_id, message.guild.roles)
    if role in user.roles:
      await message.channel.send("Yay!")```
#

ye its the identation

#

fix it on your end

#

like this

#

like this but no embed but ur rest of code

neat field
#

where it says role_id

#

remobve that and put the id

hollow zealot
#

ok

ebon island
#

As far as I am aware the mechanism by which sound is played is that the audio is broken up into 20 Ms chunks and effectively sent as a stream of those chunks

neat field
#

channel = guild.system_channel #getting system channel
if channel.permissions_for(guild.me).send_messages: #making sure you have permissions
await channel.send("I'm online!")

#

send ur code and traceback i will show u

hollow zealot
#

i tried it and the bost dosnt reply

neat field
hollow zealot
#

nope

#

oh wait i think i dont have the role

neat field
#

...

hollow zealot
#

yep.. lol

lyric apex
#

How do i find message by id in bot

hollow zealot
terse coyote
#

how to withdraw all members on guild, bots, and users?

cloud dawn
unkempt canyonBOT
#

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

Retrieves a single [`Message`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Message "discord.Message") from the destination.
hollow zealot
neat field
lyric apex
lyric apex
#

Yet its saying no attribute fetch_message

hollow zealot
neat field
#

u obv used the wrong attr

cloud dawn
neat field
terse coyote
lyric apex
#

Db

hollow zealot
neat field
neat field
hollow zealot
# neat field ye show the eror
dm = await user.create_dm()
if any(word in msg for word in Bannedword)
    if message.channel != "πŸ“βž€logs":
      await deletemsg
      response = await dm.send(f"<@{message.author.id}> hey watch your language! :Bonk:"```
cloud dawn
# lyric apex

Well you can use either, Context, Messageable, DMChannel, GroupChannel, Member, TextChannel and User

#

Not Bot or Client.

hollow zealot
cloud dawn
lyric apex
neat field
lyric apex
#

Then how i do it

cloud dawn
neat field
#

^^

#

for your case its probably a textchannel,, so get the textchanel object then fetch the message

hollow zealot
#

ugh replit is so slow

lyric apex
neat field
#

or wtv object u have

#

show code maybe i can help

hollow zealot
# neat field ye show the eror
dm = await user.create_dm()
if any(word in msg for word in Bannedword)
    if message.channel != "πŸ“βž€logs":
      await deletemsg
      response = await dm.send(f"<@{message.author.id}> hey watch your language! :Bonk:"

can u just fix the code? cause it seems that i cant run the repl

neat field
#

whats the error

lyric apex
hollow zealot
#

there we go i ran it!

vale wing
#

If it's low I would recommend learning a bit more, if it is decent your code still needs improvements I can tell you about

hollow zealot
hollow zealot
vale wing
#

Search for some courses

hollow zealot
vale wing
#

You can't do that

vale wing
#

I mean you can but it's not a good idea

hollow zealot
vale wing
#

Replit for discord bots is not a good idea as well

hollow zealot
vale wing
#

Don't start learning python from discord bots, learn the python itself at least to OOP level

#

You can't make bots without that knowledge

hollow zealot
supple thorn
hollow zealot
hollow zealot
hollow zealot
#

cause i have more experience on it

supple thorn
#

Why

supple thorn
hollow zealot
terse coyote
#

how to compare author's and member's roles of ?

feral jacinth
#

what exactly is ur issue

dawn shard
#

You probably havent enabled the message content intent

terse coyote
#
@client.event
async def on_message_delete(message):
    msg = str(message.author)+ 'deleted message in '+str(message.channel)+': '+str(message.content)
    channel = discord.utils.get(message.guild.channels, id = 974273896377368606)
    await channel.send(msg)
dawn shard
#

yeah

terse coyote
dawn shard
#

since you have message.content in your code

terse coyote
#

yeah

#

it's message content

#

heh

terse coyote
hollow zealot
#

nope

terse coyote
#

u will have an error 'Event loop is closed' if u will be use intent item without turned-on intent in discord developers portal

hollow zealot
#

what?

flint isle
hollow zealot
slate swan
#

:bonk:

#

lmfao

hollow zealot
flint isle
#

Thx love it

hollow zealot
#

ok??

terse coyote
#

I will tell you a secret:
when i the first time get this error, i search solution mb 2 days, because i thought it's asyncio error

slate swan
#

if u forgot to request for it, then you'll prolly have to wait till verification shit

#

and after that, request for intent again by making new ticket

terse coyote
#

help meeeeeee

slate swan
#

😐 do u want water?

#

lmfao

terse coyote
#

nono

#

i replied not that message

#

how to compare author's and member's roles of ? omg who can help me? i think it's not a over hard question

slate swan
terse coyote
#

yes

#

whose role is higher

slate swan
#

oohoo

#

then get their roles & iirc, the roles are arranged in increasing order of their position

#

so from there.. get the last role from the list & check its position.. then compare it @terse coyote

terse coyote
#

how to then compare it.... idk😭

slate swan
terse coyote
#

oh

slate swan
#

!d discord.Member.roles

unkempt canyonBOT
#

property roles```
A [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role") that the member belongs to. Note
that the first element of this list is always the default [β€˜@everyone](mailto:'%40everyone)’
role.

These roles are sorted by their position in the role hierarchy.
terse coyote
#

where

slate swan
#

this will give u the list of roles that they have

#

and the list will be in increasing order of their roles as per their position

jagged adder
#

i was inspired recently to create a private bot for my server. now, im essentially new to coding, python or otherwise so forgive my ignorance πŸ˜›
what im currently stuck on is creating an input for a RPG style discord bot, where i can create branches (think of a make your own adventure book). However i cannot find how to stop my code from simply looping itself. A friend (he writes other coding languages but not Python) suggested using States, but they seem rather complicated in Python (at least to my brain).
In essence, im trying to create a number of "rooms" which you can enter and leave, and the program remembers where you are between inputs.
I suspect the answer is very simple, but any help would be hugely appreciated!

#

i can get my bot to reply to the first command (in my case i set it to &start) but then it loops back and wont accept any further commands except for start again. its clearly not awaiting further input, but idk how to code it so it does. ie, type so if i &start, then i can choose option A or B which then branches out further, and so on

flint isle
#

Umm I put this code and it aint workin```py
await self.bot.invoke('ping')

slate swan
#

and you're suppose to pass command object, not command name

#

!d discord.Embed give look here

unkempt canyonBOT
#

class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, timestamp=None)```
Represents a Discord embed...
slate swan
#

!d discord.ext.commands.Bot.wait_for

unkempt canyonBOT
#

wait_for(event, /, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Waits for a WebSocket event to be dispatched.

This could be used to wait for a user to reply to a message,
or to react to a message, or to edit a message in a self-contained
way...
slate swan
#

@jagged adder ^^ for u

#
discord.Embed(
    title = "Netflix",
    color = discord.Color.red(),
    description = 'Watch movies & Shows'
)
``` this shuold do
#

and from here do what u suggested to other ppl :>

#

use random module & send it in description or where u want

#

my answer is still same

cloud dawn
#

!d random.randint

unkempt canyonBOT
#

random.randint(a, b)```
Return a random integer *N* such that `a <= N <= b`. Alias for `randrange(a, b+1)`.
slate swan
#

!d random.choice he should use

unkempt canyonBOT
#

random.choice(seq)```
Return a random element from the non-empty sequence *seq*. If *seq* is empty, raises [`IndexError`](https://docs.python.org/3/library/exceptions.html#IndexError "IndexError").
slate swan
#

he already has list

jagged adder
# slate swan <@413515867960377346> ^^ for u

could this be used in my instance where i want to navigate around say a room, looking at different things (my programmed inputs, ie A or B in this case)?
And how would i be able to loop back to the same spot? tbh it would be very helpful if u could take a look at the code in dms and make sure it would work as intended

slate swan
#

bro.. use random.choice to get the random response.. and put it in embed πŸ’€

slate swan
jagged adder
#

soz :p

slate swan
#

and, you can take input

#

but for going back to same spot.. you'll have to think of it yourself πŸ€”

#

no

#

it is self explanantory

#

and you're adivcing other ppl to read docs.. 😐 i think u should go and read docs of random & discord.Embed

jagged adder
slate swan
#

wtf is sstate command 😐 i'm feeling dumb

#

i only knwo about prefix & slash command.. wot is state command?

#

u can ask for help here anytime

#

lmao

slender night
#

I had to delete it because mods will think its an advertisement.

slate swan
slate swan
slate swan
#

nor do I

#

πŸ’€ LMFAOO

jagged adder
#

command is the wrong term... keyword maybe
idk the techy name tbh

slate swan
#

understandable 😐

#

but no, i still don't know what is state command

#

lmao

jagged adder
#

yup

dull terrace
#

map_match + 1 % 100 this is going to do 1 % 100 first isn't it?

kindred epoch
#

There's nothing as a state command

slate swan
jagged adder
#

the closest thing i can find in python r state patterns, and they seem alot more complicated

#

πŸ€·β€β™‚οΈ

slate swan
#

...

kindred epoch
#

Read what the error says

#

Can you respond to a channel?

#

Yea

#

So what do you do in a channel?

jagged adder
kindred epoch
#

Send what?

slate swan
#

that's a different thing

jagged adder
#

gl yall

slate swan
#

πŸ’€ getting message content & sending message, are they same?

slate swan
#

u aren't replying my questino.. yes or no?

#

are they same?

#

!d discord.Message.content

unkempt canyonBOT
slate swan
#

!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...
slate swan
#

they are different

#

how do you even expect message content without any reason

#

so use channel.send to send the message, why using respond.. and why linking message content issue with this

#

anyways, asheley has answered both of your queries above

#

😩 that's not related to send shit then it 's related to message content

kindred epoch
#

!d discord.Message

slate swan
visual island
placid skiff
slate swan
slender night
#

Who else don't like the new dev portal? It like stucks and all

slate swan
#

its the same..

kindred epoch
placid skiff
#

i think due to math logic, addition and subtraction are resolved as last, the % is considered as the reminder of a division

kindred epoch
#

This should work

slate swan
#

then don't advice other ppl to read docs :>

#

if you don't do it yourself :>

slate swan
#

not other than few stuffs tho.. interface is still same

#

ghost ping?

visual island
slate swan
#

ok

#

good luck!

#

gg

slate swan
#

asking is okay as long as you help yourself too, asking for code & stuff without reading docs.. is spoonfeeding :>

#

@slate swan This is confusing πŸ˜” how do I create an event in a plugin?

slate swan
#

the only change is that you use @plugin.command/@plugin.listener instead of bot

#

Oh you meant an event

#

well, plugin.listener is your deal

nimble plume
#

is it a slash?

slate swan
slate swan
nimble plume
#

what I implementimplement

slate swan
#

the way of making them are same

maiden fable
nimble plume
#

@plugin.plugin.slash

slate swan
placid skiff
nimble plume
#

what's that

slate swan
nimble plume
#

implementation

slate swan
heady sluice
#

ew

nimble plume
#

cringe

slate swan
#

you don't need to read it if you don't like it.

#

Never mentioned you or was targeted at you

heady sluice
#

I can't control what I want to read before I read it sorry

nimble plume
#

☺️

placid skiff
nimble plume
#

new emoji

#

πŸ₯΄πŸ‘ΏπŸ‘ΉπŸ‘ΊπŸ‘»πŸ€‘πŸ™ˆ

slate swan
#

@slate swan also, isnt there a way to get the command name (cooldown) and remaining time for a cooldown to end?

nimble plume
#

how can I cooldown a cog

placid skiff
#

bruh

slate swan
unkempt canyonBOT
#

cog_check(ctx)```
A special method that registers as a [`check()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check")
for every command and subcommand in this cog.

This function **can** be a coroutine and must take a sole parameter,
`ctx`, to represent the [`Context`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Context "discord.ext.commands.Context").
slate swan
#

use this to implement "Cog" cooldowns

#

you would be returning commands.cooldown

slate swan
slate swan
placid skiff
#

however if you have slash commands this will not work for them

#

uh i didn't mention the doc

slate swan
lyric apex
#

How Can I Make Transcript Of Messages in a channel*

slate swan
# slate swan πŸ˜” thanke

Error.context will give you the SlashContext so
command : error.context.command
try after : error.retry_after
where error is an lightbulb.CommandIsOnCooldown exception class

#

hm I see, thanks

nimble plume
#

Hi bro

#

hi

flint isle
slate swan
nimble plume
#

how do I get all cmd in a cog

placid skiff
#

!d discord.ext.commands.Cog.get_commands

unkempt canyonBOT
#

get_commands()```
Returns the commands that are defined inside this cog.

This does *not* include [`discord.app_commands.Command`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.Command "discord.app_commands.Command") or [`discord.app_commands.Group`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.Group "discord.app_commands.Group")
instances.
flint isle
nimble plume
nimble plume
#

weird

flint isle
#

It's guilds lol

nimble plume
#

u copy cat

#

namkine

uncut portal
flint isle
#

^w^

uncut portal
#

should be self.get_commands() at a glance but I don't use discord libraries

nimble plume
#

1

#

OK

vale wing
#

What is servers

uncut portal
#

try client.get_guilds(guild).member_count

nimble plume
#

guilds

vale wing
#

There's no definition of it in your code

#

Then put guilds instead of it

nimble plume
#

ok

uncut portal
#

nvm hold up we could do this better

nimble plume
#

also why list()

vale wing
#

Yeah

#

It is already a list lol

slate swan
#

How can I run a command which is having 3 arg with 2 args sent by the user?

uncut portal
#

it probably returns an iterator

vale wing
#

!d discord.ext.commands.Bot.guilds

unkempt canyonBOT
vale wing
#

Check the return type

uncut portal
#

there is no need for it then

grand shell
#
btn.disabled = not user.top_role.permissions.administrator

hey, im trying to disable a button if a user isn't an admin

nimble plume
#

ok

grand shell
#

but for some reason it only works if @everyone has admin

vale wing
#

You confused yourself (or I did)

grand shell
vale wing
#

Remove not

#

It is disabled = ... not enabled

nimble plume
#

huh

vale wing
#

Imagine if user has admin perm, the logic would look like this in your case

btn.disabled = not True
==
btn.disabled = False
# button is enabled```
#

Eh wait

nimble plume
#

bro

vale wing
#

I just explained to myself that I was wrong

#

Stupid logic

nimble plume
#

!e

unkempt canyonBOT
#
Missing required argument

code

#
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
quaint epoch
grand shell
#

ah got it, thanks guys

vale wing
#

@grand shell do you update your message after you have disabled the button

grand shell
#

yep

#

its fixed now :))

coral vessel
#

why i always get this?

maiden fable
empty kernel
#

If I have several different (but related) questions about bot permissions, is that generally easier/better to ask in this channel or open a help channel? It's less "code" related and more general permissions related

nimble plume
#

less codenu can ask here

#

big code u can ask that too

scarlet sorrel
#

did yall know you can send messages that have no text field at all

#

no text, not even ZWJ

slate swan
#

maybe invis character

#

β€Ž

#

like this

#

yes

#

β€Ž

slate swan
#

`

empty kernel
# nimble plume less codenu can ask here

Well, I may include several screenshots so it's more clear what I'm asking about and I don't want all the images to push other questions out of the way or have them get lost. I think I'll open a help channel once I'm done at work, or have a little downtime. Thanks!

slate swan
#

lol

slate swan
scarlet sorrel
#

as i said, no text field

#

no gap

slate swan
slate swan
scarlet sorrel
#

so many emojis and broken sentence structure

#

talking to ai is easier to understand then people these days

slate swan
#

β€Ž

scarlet sorrel
#

no idea what "empty have a volume in discord" means

slate swan
#

yo wait

scarlet sorrel
#

it has to be a bot

slate swan
#

that invis character has a low volume than the normal text

scarlet sorrel
#

no

paper sluice
slate swan
#

it's only till the pfp

scarlet sorrel
#

no

slate swan
scarlet sorrel
#

see in the screenshot, there is no gap between the reaction and the name

slate swan
#

tf typing

#

auto correct

scarlet sorrel
# slate swan β€Ž

if we could use reactions, you would see that your message here still has the exact same volume

slate swan
#

😐 true, i tried that.. not happening 😐

#

rip

scarlet sorrel
#

has to be a bot

slate swan
#

😐 ask that guy, how he did lmao

#

no

slate swan
#

didnt add reaction by myself

#

MAYBE

#

akito is the bot,

scarlet sorrel
#

i got it through an error in my code

slate swan
#

OwO

#

let me download discord app hec

scarlet sorrel
#

never seen something so rare in discord

slate swan
#

can't typ

slate swan
paper sluice
scarlet sorrel
slate swan
#

πŸ’€ i used to be one of them tho

#

using browser

slate swan
scarlet sorrel
paper sluice
slate swan
#

😐 i used it for like 3 or some months

#

cuz i didn't know that discord has desktop client πŸ’€

scarlet sorrel
#

both of you are 2020 accounts

slate swan
#

yeye

paper sluice
#

i had a shit pc, i couldn't have discord and mincreaft open at the same time 😐

slate swan
#

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

slate swan
scarlet sorrel
#

hahaha

slate swan
#
Ignoring exception in on_command_error
Traceback (most recent call last):
  File "C:\Users\ego\anaconda3\lib\site-packages\discord\ext\commands\core.py", line 200, in wrapped
    ret = await coro(*args, **kwargs)
  File "C:\Users\ego\Desktop\astral\cogs\information.py", line 162, in userinfo
    await ctx.send(embed=e)
  File "C:\Users\ego\anaconda3\lib\site-packages\discord\ext\commands\context.py", line 698, in send
    return await super().send(
  File "C:\Users\ego\anaconda3\lib\site-packages\discord\abc.py", line 1536, in send
    data = await state.http.send_message(channel.id, params=params)
  File "C:\Users\ego\anaconda3\lib\site-packages\discord\http.py", line 501, in request
    raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In embeds.0.fields.0.value: This field is required

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

Traceback (most recent call last):
  File "C:\Users\ego\anaconda3\lib\site-packages\discord\client.py", line 375, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\ego\Desktop\astral\cogs\aevents.py", line 46, in on_command_error
    raise error
  File "C:\Users\ego\anaconda3\lib\site-packages\discord\ext\commands\bot.py", line 1325, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\ego\anaconda3\lib\site-packages\discord\ext\commands\core.py", line 948, in invoke
    await injected(*ctx.args, **ctx.kwargs)  # type: ignore
  File "C:\Users\ego\anaconda3\lib\site-packages\discord\ext\commands\core.py", line 209, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In embeds.0.fields.0.value: This field is required

code: https://paste.pythondiscord.com/apodopazif

scarlet sorrel
slate swan
#

error is self explanantory

slate swan
slate swan
#

Wow, didn't notice that yet πŸ’€

scarlet sorrel
slate swan
slate swan
#

self explanantory erorr

#

No shit sherlock, look at the code, it should work but it's still giving me the error

#

Bro discord login page has tf light theme

#

I provided the code for a reason, didn't i?

scarlet sorrel
#

4x older then yours

slate swan
slate swan
scarlet sorrel
#

that would be so funny

#

its not tho

slate swan
#

Try clicking it

scarlet sorrel
#

i did

slate swan
#

show

slate swan
scarlet sorrel
#

just works as normal reaction, but it does not delete the message like it normally does

slate swan
#

Ss

#

screenshot

#

I can't beleive

scarlet sorrel
slate swan
#

Damn

scarlet sorrel
#

yep

#

ultra rare phenomenon

slate swan
#

can u send me server link in dm i wana see

scarlet sorrel
#

its in dms

#

can probably reproduce it tho

#

yea i can

slate swan
#

2 15 am

scarlet sorrel
#

im not 10

slate swan
#

6:34pm 🀝

scarlet sorrel
#

sleep when i want lol

slate swan
#

Yo mystry solved it has space

#

It was a glitch

paper sluice
#

?

slate swan
#

There was a space

#

how can i check if the same server invite is already inside the txt file and then send a message?

slate swan
paper sluice
#

why isn't it showing up then?

slate swan
#

Glitch

#

I can see

#

But they can't

paper sluice
#

ah k

slate swan
#

with open(sparky.txt) as f:
a = f.readlines()
It return a list iirc

paper sluice
#

u need to call it πŸ˜…

slate swan
#

yes it does

#

but its a callable as ryuga mentioned

slate swan
#

I'm typn on dc

paper sluice
slate swan
#

Ded chat

#

?

quaint epoch
#

the i realized, oh ()

slate swan
#

its there

#

U also want the channel id in which the msg is in

#

If u want to fetch

#

a = bot.get_message(id) or await bot.fetch_channel(channelid).fetch_message(id)
a.edit("hi")

terse coyote
#

how to use a commands in bot's dm?

outer violet
terse coyote
#

can i use the command in dm bot?

zinc reef
heady sluice
#

cuz which method do you await?

slate swan
#

depends on the library

heady sluice
#

await bot.fetch_channel(channelid).fetch_message(id)

slate swan
#

!d discord.TextChannel.fetch_message is the way to go

unkempt canyonBOT
#

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

Retrieves a single [`Message`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Message "discord.Message") from the destination.
slate swan
heady sluice
slate swan
#

ah, why did he even use fetch

#

there's 0.01% for which get_ wont work channel

heady sluice
#

right

#

unless you don't have guilds intents

#

which is weird by itself

heady sluice
#

await await bot.fetch_channel(channelid).fetch_message(id)

slate swan
#

await (await bot.fetch_channel(c_id)).fetch_message(m_id)

heady sluice
#

bru

#

won't it be tuple(channel).fetch_message then?

slate swan
#

no why

#

!e a = (1); print(type(a))

unkempt canyonBOT
#

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

<class 'int'>
heady sluice
#

well

slate swan
#

only if i added a , in the ()s

grand shell
#

hey guys, is there an event to detect when categories are deleted? i couldnt find one in the docs

heady sluice
#

!d discord.on_guild_channel_delete

unkempt canyonBOT
#

discord.on_guild_channel_delete(channel)``````py

discord.on_guild_channel_create(channel)```
Called whenever a guild channel is deleted or created.

Note that you can get the guild from [`guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.GuildChannel.guild "discord.abc.GuildChannel.guild").

This requires [`Intents.guilds`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.guilds "discord.Intents.guilds") to be enabled.
slate swan
#

category channels are channels too, so yeah

grand shell
#

ahh ok

#

thats weird haha. ty

terse coyote
#

how to make the bot display everything in the console in dm to me?

slate swan
#

you mean print all the dms of your bot?

kindred epoch
slate swan
#

they edited the message~

kindred epoch
#

If an error occurs it appears on the console

#

They want that in dm

unkempt canyonBOT
#

discord.on_error(event, *args, **kwargs)```
Usually when an event raises an uncaught exception, a traceback is
printed to stderr and the exception is ignored. If you want to
change this behaviour and handle the exception for whatever reason
yourself, this event can be overridden. Which, when done, will
suppress the default action of printing the traceback.

The information of the exception raised and the exception itself can
be retrieved with a standard call to [`sys.exc_info()`](https://docs.python.org/3/library/sys.html#sys.exc_info "(in Python v3.10)")...
slate swan
#

use this event, and send the exception to your dms

kindred epoch
#

Only thing I can think of that prints in the console

terse coyote
#

how to make the bot put a reaction to a random message

dull stirrup
#

I need some discord.py help in #help-mango I can't figure this out lmao it's something simple too and I know it

regal pulsar
#

guild is an integer

#

you need a guild object

slate swan
#

my discord command takes a argument and returns the first word of the sentence of the argument, how to make it take all the sentence?

slate swan
#

yeah i did, ty

dense swallow
#

so it will look like this: async def test(ctx, *, reason)

sick birch
#

|| like this? ||

#

||⬜ || or like this?

feral lichen
#

/spoiler

sick birch
#

||⬜ ||

#

hmm

feral lichen
sick birch
#

wish it was bigger

feral lichen
#

😩

#

/spoiler

sick birch
#

bots can't do that

feral lichen
#

oh

#

lol

sick birch
#

|| like this ||

#

They can't run slash commands, I mean

#

!e

spoiler_text = "Hello, world!"
print(f"|| {spoiler_text} ||")
unkempt canyonBOT
#

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

|| Hello, world! ||
sick birch
#

Would look regular on discord

slate swan
#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: InvalidArgument: emoji argument must be str, Emoji, or Reaction not NoneType.

#
@bot.command(pass_context=True)
async def ticket(ctx):
    def check(reaction, user):
        return str(reaction) == 'πŸ“©' and ctx.author == user


    guild = ctx.guild
    embed = discord.Embed(
        title = 'Ticket system',
        description = 'React πŸ“© to make a ticket.',
        color = 0
    )

    embed.set_footer(text="ticket system")
    author = ctx.author
    msg = await ctx.send(embed=embed)
    await msg.add_reaction("πŸ“©")
    emoji = bot.get_emoji(int(976556686674362428))
    overwrites = {
        guild.default_role: discord.PermissionOverwrite(view_channel=False),
        ctx.author: discord.PermissionOverwrite(view_channel=True)
    }
    def channlcreate(channel):
      guild.create_text_channel(name=f'ticket - {ctx.author}')
    await bot.wait_for("reaction_add", check=check)
    channel = await guild.create_text_channel(name=f'ticket - {ctx.author}', overwrites=overwrites)
    channlcreate(channel)
    await channel.send("Hewo")
    await msg.remove_reaction(emoji, author)```
sick birch
#

what is servers?

#

A list of IDs?

slate swan
#

i mean the emoji is a integer as well so idk, maybe i copied the wrong emoji id

sick birch
#

I'm asking what servers is

#

Right

#

Looks similar to servers = ...

heady sluice
#

bot.guilds ig

sick birch
#

It seems to me like it's a list of ids

heady sluice
#

replace servers with guilds

#

seems like a viable option

#

think -> write

#

is this the code that you have now?

#

with this error?

sick birch
#

Please, what is servers? Its data type?

#

You need to send to a discord.Messageable

heady sluice
#

nakime you've been here for like... 2 months now

slate swan
#

ctx.send()

#

bot.send is very old method (in old version)

sick birch
#

Nowhere, I'm telling you only discord.Messageable inherited classes have a send() method

heady sluice
#

isn't the first param an Interaction in pycord?

#

slash

slate swan
#

how to get emoji id

heady sluice
#

right click on discord

#

copy ID

#

done

slate swan
#

no this is not a thing in discord

#

it'll copy the message id and there's no option for emojis

#

:3

heady sluice
#

470903994118832130

slate swan
#

i also tried this and it does not work as well

#

\πŸ˜‚

#

thats what happens and no id shows

heady sluice
#

not with emojis like this

#

you don't even need the IDs on basic emojis

#

await message.add_reaction("\😭")

slate swan
#

bot.get_emoji requires int as well to for remove_reaction

heady sluice
#

!d discord.Message.remove_reaction

unkempt canyonBOT
#

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

Remove a reaction by the member from the message.

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

await message.remove_reaction("\😭", member)

#

replace 😭 with the right emoji of course

vocal plover
#

is it flex time?

slate swan
heady sluice
slate swan
#

vco is gonna flex his 22 domains

heady sluice
#

of course he does

vocal plover
slate swan
vocal plover
#

I got another one today sadcat

#

I couldnt stop myself

heady sluice
vocal plover
#

not quite that many members lol

heady sluice
#

ah he ignored the earnings check

slate swan
#
@bot.command()
async def close(ctx):
    channeld = ctx.channel.id
    channeled = bot.get_channel(channeld)
    await ctx.delete_channel(channeled)``` ![sad](https://cdn.discordapp.com/emojis/919966376737771540.webp?size=128 "sad")
heady sluice
#

what

oblique adder
#

How do I check if the command is invoked from ctx.invoke and not from prefix command

slate swan
#

Command raised an exception: AttributeError: 'Context' object has no attribute 'delete_channel'

heady sluice
#
@bot.command()
async def close(ctx):
    await ctx.channel.delete()
vocal plover
#

only if you have them all cached

slate swan
#

would be good tbh if u add a secret function that makes a invite to every bot user on join or when using a common command

keen mural
#

if were making a cmd like a giveaway, how could i make it so it keeps going even after i stop and start the bot again?

#

or make it so the cool down for cmds stays after restart too

heady sluice
#

no

#

!d discord.Client.users

unkempt canyonBOT
heady sluice
#

having something cached means it's in the cache

#

which is stored in your Bot instance

keen mural
#

if were making a cmd like a giveaway, how could i make it so it keeps going even after i stop and start the bot again?
or make it so the cool down for cmds stays after restart too

heady sluice
#

you mean after closing the script

#

and starting it again

keen mural
#

yeah

heady sluice
#

you cannot

keen mural
#

then how do other bots do it

heady sluice
#

you'd have to store data about the giveaway somewhere

heady sluice
#

I think most bots don't use asyncio.sleep

#

they calculate the time the giveaway has to end at

#

store the time in a database and start a task that checks if a giveaway has ended every 1 minute

keen mural
#

hm

#

so i would have to make the time a date instead of time in seconds

slate swan
#

hi any1 know good github repo with profesional discord bot i wanted to see how commands are built?

oblique adder
#

but for now i just get the ctx.message and check if it startwith prefix

flint isle
oblique adder
flint isle
#

Umm can I get an example of invoking a command?

torn sail
#

!d discord.ext.commands.Context.invoke

unkempt canyonBOT
#

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

Calls a command with the arguments given.

This is useful if you want to just call the callback that a
[`Command`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") holds internally...
flat solstice
#

can someone remind me how to make a combination check for a command in dpy stable? so I can check if the user has admin perm and can also check if one of my custom checks passes?

torn sail
#

!d discord.ext.commands.check_any

unkempt canyonBOT
#

@discord.ext.commands.check_any(*checks)```
A [`check()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if any of the checks passed
will pass, i.e. using logical OR.

If all checks fail then [`CheckAnyFailure`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CheckAnyFailure "discord.ext.commands.CheckAnyFailure") is raised to signal the failure.
It inherits from [`CheckFailure`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")...
flint isle
slate swan
#

!d discord.ext.commands.Bot.get_command

unkempt canyonBOT
#

get_command(name, /)```
Get a [`Command`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") from the internal list
of commands.

This could also be used as a way to get aliases.

The name could be fully qualified (e.g. `'foo bar'`) will get
the subcommand `bar` of the group command `foo`. If a
subcommand is not found then `None` is returned just as usual...
flat solstice
# torn sail !d discord.ext.commands.check_any

thanks, do you mind giving me a example of how to use it? I have this py @commands.check_any(has_permissions(administrator=True), checks.is_admin() which I got from trying to combine py @commands.has_permissions(administrator=True), checks.is_admin() and py @checks.is_admin() which looks like this py def is_admin(): def predicate(ctx): if ctx.author.id not in ctx.bot.config.admins and ctx.author.id not in ctx.bot.config.owners: raise commands.NotOwner() else: return True return commands.check(predicate)

pallid meadow
#

Don’t believe so no

#

Buttons can only be added to messages etc iirc

#

@slate swan

#

You just get the total seconds and use the discord time stamp format

#

If it’s a date time object you should be able to call timestamp

#

I believe it’s just an attribute

#

Not a method

#

Try without the brackets

torn sail
#

!d discord.utils.format_timestamp

unkempt canyonBOT
#
NEGATORY.

No documentation found for the requested symbol.

torn sail
#

something like that

pallid meadow
#

Don’t think that’s a thing

torn sail
#

!d discord.utils.format_dt

unkempt canyonBOT
#

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

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

Oh it is

slate swan
#

in case you use that, it returns a float, so you gotta use int(datetime.timestamp()) to convert it to am usable timestamp integer

#

*an

austere vale
#
  @commands.command()
  async def play(self, ctx,url):
    if ctx.author.voice is None:
      await ctx.send('You are not in a voice channel.')
    if ctx.guild.voice_client is None:
      await ctx.author.voice.channel.connect()
    else:
      await ctx.author.voice.channel.move_to()

can someone help me?

#

im just trying to get it to move to the channell im in

torn sail
#

because u need go move the voice_client not the voice channel

slate swan
#

VoiceProtocol has no move_to method.

torn sail
#

VoiceClient does

slate swan
#

VoiceClient is not a thing, voice_client returns a Voice Protocol

#

!d discord.Guild.voice_client

unkempt canyonBOT
#

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

you need to use guild.me.move_to

torn sail
#

oh waitn

#

didnt read properly

#

yeah that works although i think most libs will have move_to on their voice client class

slate swan
#

πŸ˜”they should be mentioning it explicitly though

austere vale
# slate swan you need to use `guild.me.move_to`
  @commands.command()
  async def play(self, ctx,url):
    if ctx.author.voice is None:
      await ctx.send('You are not in a voice channel.')
    if ctx.guild.voice_client is None:
      await ctx.author.voice.channel.connect()
    else:
      await ctx.guild.me.move_to()
slate swan
slate swan
austere vale
#

oh do i put author.voice.channel in the parentheses

slate swan
#

if its your own ctx.author.voice.channel

austere vale
#

ohh

slate swan
#

yes sir

austere vale
#

tysmi t worked

sick birch
#

I'm guessing member is actually a discord.Role

#

Can I see the member definition?

slate swan
#

you can just do member = member or interaction.user

potent spear
sick birch
#

long story short it checks for truthy values in member and interaction.user and assigns member whichever one is truthy first

dapper tendon
#

how fix this ?

sick birch
#

so if member exists, then member = member, if not, member = interaction.user

sick birch
potent spear
dapper tendon
dapper tendon
potent spear
sick birch
#

It seems like you're running the code on replit, so installing it on your local machine isn't going to work

dapper tendon
sick birch
#

Yes, but did you install it on replit?

dapper tendon
dapper tendon
potent spear
zinc phoenix
#

Is this what you are looking for

dapper tendon
#

@sick birch@potent spear@zinc phoenix thx

#

I only have one question

zinc phoenix
#

Np

dapper tendon
#

Can I make a music bot using Python?

potent spear
#

ofc

#

you can make anything, you just have to know how

dapper tendon
potent spear
#

trying without showing code doesn't help us that much tbh

#

also, depends on what your source is on "how to learn something"

zinc phoenix
#

But Im not really sure if thats legal

distant river
#

Hi guys, I have want to refer a command in another command and I"m not sure how to pull this through.

@client.command()
async def schedule_daily_message():
  await pie_chart(start_date= d1, end_date=d2)

@client.command()
async def pie_chart(ctx,start_date, end_date):

I keep getting this error:

TypeError: missing 1 required positional argument: 'ctx'

distant river
#

is there a way to by pass the ctx?

potent spear
#

as you can see in the docs, commands start with ctx as first arg

distant river
#

I'm nto sure how to input a ctx

potent spear
distant river
#

in my schedule_daily_message()

zinc phoenix
#

"schedule_daily_message(ctx, your arguments)"

potent spear
#

also "scheduling a daily message" seems more like that should be a task than a command

distant river
#

I just want schedule_daily_message() without any arguments

zinc phoenix
#

I know but you need ctx in order for the command to work

distant river
#

πŸ‘€

potent spear
#

a task doesn't take any args

distant river
potent spear
#

your decorator is just incorrect

zinc phoenix
#

Is it possible to download a file from the user

potent spear
#

ofc

#

that's message.attachments

zinc phoenix
#

Can you show me a code example

potent spear
#

!d discord.Message.attachments

unkempt canyonBOT
zinc phoenix
#

Thanks

potent spear
#

you'll want to get one of those attachments, this object has an async save method

zenith basin
potent spear
#

you can ctrl+f on load_extension

#

have you realised that the code you wrote where the status changes every 3 seconds gets you ratelimited for sending too much API requests?

potent spear
dapper tendon
zenith basin
# potent spear https://gist.github.com/Rapptz/6706e1c8f23ac27c98cee4dd985c8120
class MyBot(commands.Bot):
    def __init__(self):
        super().__init__(command_prefix='!',help=PrettyHelp(),intents=discord.Intents.all())
  

    async def setup_hook(self):
        self.background_task.start()
        self.session = aiohttp.ClientSession()
        for ext in self.initial_extensions:
            await self.load_extension(ext)

    async def close(self):
        await super().close()
        await self.session.close()

    @tasks.loop(minutes=10)
    async def background_task(self):
        print('Running background task...')

    async def on_ready(self):
        print('Ready!')

bot = MyBot()
bot.run(token)
#
AttributeError: 'MyBot' object has no attribute 'initial_extensions'
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x00000212A235A3A0>
sick birch
zenith basin
dapper tendon
#

@potent spearOk give me the solution to make the code work

sick birch
#

No, streaming any content off YouTube is in violation of terms of service

sick birch
zenith basin
potent spear
sick birch
#

!ytdl

unkempt canyonBOT
#

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

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

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

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

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

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

lets see here

zenith basin
potent spear
zenith basin
potent spear
#

if you typed it out yourself or understood what the code I linked said, you wouldn't encounter that problem

sick birch
#

Clause 3C seems to agree with you

zenith basin
#

😦

potent spear
#

initial_extensions is just a list of cog names the code example defined...

#

in your case, just replace the for loop in the example with how you'd loop through your cogs previously to load them

zinc phoenix
#

Can anyone show me a code example of download files command for the bot

#

I cant really understand the message.attachment

#

Nvm

shadow crystal
#

i have question. for anyone who makes discord bots with 3rd party apis (like roblox) DM ME

potent spear
#

most devs implement API's at some point...

kindred plinth
#

magicSix(5, 5) Output: Not a magic 6.
magicSix(6, 5) Output: Magic 6!
magicSix(4, 2) Output: Magic 6!
magicSix(4, 10) Output: Magic 6!
How can I create A function like this, where a user puts in two inputs and one can either equal six or both added together can equal six

potent spear
kindred plinth
#

omg someone sent me here

#

bruh then where do I get advice

potent spear
#

in any help channel

kindred plinth
#

I dont have one of those

zenith basin
#

My code:

class MyBot(commands.Bot):
    def __init__(self):
        intents = discord.Intents.default()

        super().__init__("!", intents=intents)
        self.initial_extensions = ['Cogs.Safety']

    async def setup_hook(self):
        self.background_task.start()
        self.session = aiohttp.ClientSession()
        for ext in self.initial_extensions:
            await self.load_extension(ext)




    async def close(self):
        await super().close()
        await self.session.close()

    @tasks.loop(minutes=10)
    async def background_task(self):
        print('Running background task...')


    async def on_ready(self):
        print(f'Logged in as {self.user} (ID: {self.user.id})')
        print('------')


bot = MyBot()
bot.run(token)

I can't use cogs commands

kindred plinth
#

this says its a question asking one

potent spear
#

yeah, but it should be related to discord bots

kindred plinth
#

okay then where do I go

flint isle
#
await self.bot.invoke(self.bot.command.get_commands())

error

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

Traceback (most recent call last):
  File "C:\Users\David Powell\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\interaction_bot_base.py", line 1346, in process_application_commands
    await app_command.invoke(interaction)
  File "C:\Users\David Powell\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\slash_core.py", line 594, in invoke
    raise CommandInvokeError(exc) from exc
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'function' object has no attribute 'get_commands'
kindred plinth
#

can soemone help please

potent spear
dusky pine
#

what do you want to do with that code

zinc phoenix
#

Im having some problems with the save command, can anyone help

visual island
zinc phoenix
#

The error is "Ignoring exception in command None:
discord.ext.commands.errors.CommandNotFound: Command "save" is not found"

flint isle
dusky pine
flint isle
# dusky pine referenced earlier? show example
    @commands.command(name="ping")
    async def ping(self, inter: disnake.ApplicationCommandInteraction):
        """Get the bot's current websocket latency."""
        await inter.response.send_message(f"Pong! {round(self.bot.latency * 1000)}ms")

    @commands.slash_command(name="ping", description="Checks Bot's Latency", guild_ids=guild_ids)
    async def ping(self, inter: disnake.ApplicationCommandInteraction):
        print ('Executing ping command via slash')
        await self.bot.invoke(self.bot.command.get_commands())```
dusky pine
#

oh, slash commands

potent spear
#

you're overwriting the function...

dusky pine
#

yeah ^^

potent spear
#

you should check out hybrid commands (can be invoked with prefix AND slash)

#

that way, you don't have to define the same command twice

flint isle
potent spear
#

I'm talking about discord py v2, you're using disnake, not sure what to do with that

flint isle
#

hrmm idk

zinc phoenix
#

Can anyone help me with the save file command

#

Heres the code

#
@bot.command()
async def savef(ctx, *stuff):
  message = ctx.author.message
  if str(message.attachments) == "[]":
    return
  else: 
    split_v1 = str(message.attachments).split("filename='")[1]
    filename = str(split_v1).split("' ")[0] 
    if filename.endswith(".docx"):
      await message.attachments[0].save(fp="savedfiles/{}".format(filename)) ```
flint isle
#

whats the error?

zinc phoenix
#

'Member' object has no attribute 'content'

#

I've read it but I need a way to get the message content

dusky pine
zinc phoenix
#

Hm

sick birch
zinc phoenix
#

Oh

#

Just changed it to ctx.message

#

My bad guys

#

Thanks for taking your time

slate swan
#

Is this a good video for how to make a leveling system? https://youtu.be/B_Zd4GTAM38

Hey!
Thanks for watching todays video, I really hope you enjoyed and join my discorddd... also subscribeee :)

LINKS -
Join my Discord - https://discord.gg/twHW4UUJGq

Set Up VSC - https://www.youtube.com/watch?v=KpzkP...

Set Up PYTHON - https://youtu.be/h4fhdhNWDKk

Anyways Thanks if you read all of this and I hope you have...

β–Ά Play video
dusky pine
#

If it uses JSON as a database

#

No

slate swan
#

It uses aiosqlite

dusky pine
#

Good

#

πŸ‘

slate swan
#

So it’s good to watch?

dusky pine
#

yep

slate swan
#

Alr thank you :)

slate swan
#

example, making tables in on_ready

#

the on_message is overdone

#

and he's creating new cursor's everywhere

sick birch
#

I generally don't recommend any of these tutorials

slate swan
#

^

#

making your own logic adds to the flexibility of your app and more customized towards your general idea of the outcome

slate swan
livid hinge
#

find a minimal example andadapt into a bot

#

search out simple(est) levelling command or something like that

slate swan
livid hinge
#

it might

#

itd be ok to start with that imo

#

and more explanation = better

#

or just look at a couple and try to write one from scratch

#

do you know the basics?

#

dont worry so much about picking the right video, as long as you see a couple you'll pick out what's important

distant river
#

does set_image not accept local image?

slate swan
#

bot = commands.bot()

stiff gorge
#

how to get the category id ?

dusky pine
#

!d discord.Client.wait_for

unkempt canyonBOT
#

wait_for(event, /, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Waits for a WebSocket event to be dispatched.

This could be used to wait for a user to reply to a message,
or to react to a message, or to edit a message in a self-contained
way...
slate swan
#

error:

#
@client.command()
async def gcreate(self, ctx, mins: int, *, prize):

  await ctx.send("Giveaway!")

  embed = discord.Embed(title="New Giveaway")
  embed.add_field(name = "Prize:", value = f"{prize}")
  end = datetime.utcnow() + datetime.timedelta(seconds=mins*60)
  embed.add_field(name = "Ends At", value = f"{end}UTC")
  embed.set_footer(text=f"1 Winner | Ends {mins} min(s) from now!")

  my_msg = await ctx.send(embed=embed)

  await my_msg.add_reaction(":tada_cyan:")

  await asyncio.sleep(mins*60)

  new_msg = await ctx.channel.fetch_message(my_msg.id)

  users = await new_msg.reactions[0].users().flatten()
  users.pop(users.index(client.user))

  winner = random.choice(users)

  await ctx.send(f"{winner.mention}")

  embed2 = discord.Embed(title="Winner!", description=f"{winner.mention}")
  embed2.set_thumbnail(url=winner.avatar_url)
  embed2.add_field(name = "Prize", value=f"{prize}")
  embed2.set_footer(text="Giveaway Ended!")

  server = ctx.guild.name

  await ctx.send(embed = embed2)
  await winner.send(f"You Won a giveaway in {server} \n Prize: {prize}")
#

code ^

spring flax
#

how would I get the code from a file using a command? Like source code of a full file

slate swan
slate swan
slate swan
quick gust
#

or

unkempt canyonBOT
torn sail
cunning osprey
#

Hi guys, I need help using discord embeds. I'm getting this error:

TypeError: _Context.send() got an unexpected keyword argument 'embed'

This is my code.

async def balance(ctx: interactions.CommandContext, user : interactions.User = None):
    async def embed(ctx):
        embed=discord.Embed(
            title="Sample Embed", 
            url="https://realdrewdata.medium.com/", 
            description="This is an embed that will show how to build an embed and the different components", 
            color=0xFF5733
        )
    await ctx.send(embed=embed)

I am using interactions, not discord.py, and I believe that is where this issue is stemming from but I would still like to use embeds... what am I doing wrong? 😧

slate swan
paper sluice
cunning osprey
paper sluice
#

yes

cunning osprey
#

Oh yayayayayayay

#

Can you link my any resources/tutorials (if possible)? That would be really helpful

paper sluice
cunning osprey
#

TYTTY

paper sluice
#

u can use the !tag command to get code samples

cunning osprey
#

Okok

#

Thank you!!

slate swan
visual island
#

It shouldn't work, you only awaited the fetch_message(), but both should be awaited

distant wing
#

^

#

use .get_channel instead

#
a = await bot.get_channel(c_id).fetch_message(m_id)
slate swan
#

AttributeError: type object datetime.datetime has no attribute β€˜timedelta’

paper sluice
#

show code

slate swan
#

Imports :

import datetime 
from datetime import datetime
from datetime import time
from datetime import timedelta
paper sluice
#
import datetime 
from datetime import datetime

why?

#

when u do datetime u get datetime.datetime and not just the module

#

the second import overwrites the first one