#discord-bots

1 messages · Page 824 of 1

viral wolf
#
  if 'word' in message.content.lower():

I'm trying to get the bot to say something when a user says either word or WOrd, but message.content.lower doesnt seem to work. Anyone have any suggestions?

manic wing
pine crypt
#

Similar to how loading cogs works, is it possible to use a for loop that will add fields to a help command?

#

I may have just found my way to automate help command

viral wolf
manic wing
manic wing
viral wolf
manic wing
pine crypt
#

From a cog, how could you find the class name of another cog?

manic wing
#

!d discord.ext.commands.Cog.qualified_name

unkempt canyonBOT
manic wing
#

Returns the cog’s specified name, not the class name
realised it said this, but ill assume that you're not setting a specific name

pine crypt
#

Instead of the filename - because my filenames are different to class names - I want the class name

#

Type e.g Misc / Admin

manic wing
#

which i dont think you have

#

give it a shot

pine crypt
#

How would I use cog.qualified_name in the code I just sent?

manic wing
#

i figured out the right one

#

cog.__cog_name__

pine crypt
#

okay

manic wing
#

you only want to use that for loading cogs

#

to get all the cogs the bot has do bot.cogs

#

!d discord.ext.commands.Bot.cogs

unkempt canyonBOT
pine crypt
#

i already have cogs loaded

manic wing
#

i know

pine crypt
#

I tried using this before and it seems closer to what I want to do

manic wing
#

do you know list comprehension?

#

walk_commands is what you want

pine crypt
#

When I try to implement walk_commands() it says it is not defined

manic wing
pine crypt
#

Not really no

manic wing
#

i wont teach it right now

#

you need to learn it

#

list comprehension is quintessential to your python

pine crypt
#

Could I have any links in order to learn list comprehension?

manic wing
#

ill link something and explain it as well

slim ibex
#

nothing to really learn. you just should know when its best to use it

#
>>> squares = []
>>> for i in range(10):
...     squares.append(i * i)
>>> squares
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]

goes to

>>> squares = [i * i for i in range(10)]
>>> squares
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]

from realpython

manic wing
#

you can do ```py
for cog in bot.cogs:

cog is an str of the cogs name

to get the cog instance its bot.cogs[cog]

eg to get the commands in a cog it would be:

for command in bot.cogs[cog].walk_commands():
print(command.name)
# you can add this to a list (lests call it cog_commands) because you dont know list comprehension
# add this to the embed

embed.add_field(
name=cog,
value=cog_commands```

#

list comprehension is a one line list

#

so to get all the commands in a cog it would be [cmd.name for cmd in cog.walk_commands()]

#

!list

unkempt canyonBOT
#

Do you ever find yourself writing something like this?

>>> squares = []
>>> for n in range(5):
...    squares.append(n ** 2)
[0, 1, 4, 9, 16]

Using list comprehensions can make this both shorter and more readable. As a list comprehension, the same code would look like this:

>>> [n ** 2 for n in range(5)]
[0, 1, 4, 9, 16]

List comprehensions also get an if statement:

>>> [n ** 2 for n in range(5) if n % 2 == 0]
[0, 4, 16]

For more info, see this pythonforbeginners.com post.

pine crypt
#

Both your examples remind me of this from when I have seen it before just that it is not known to me as list comprehension

slim ibex
#
def generate_integer_list() -> List[int]:
    """
    Generates a random list of integers

    Returns
    -------
    List[int]
        A list of integers generated randomly
    """
    int_list = [randint(0, 100) for _ in range(randint(2, 10))]
    int_list.sort()

    return int_list

this is an example of a function i made that generates a random list of integers with elements that can be in between 0 and 100, and there can be at least 2 elements and at most 10 elements. its made with list comp

manic wing
#

seems pretty pointless

slim ibex
#

its not related to anything discord bot

#

it was just an example i have

pine crypt
#

so would it be something like for cog in but how would you get all cogs in a ./cogs folder?

manic wing
#

you just do bot.cogs and it gives you all the cogs your bot has

pine crypt
#

ah okay

#

like this?

manic wing
#

sort of

#

cog returns the str name of the cog

#

so that would probably be in name

#

and to get the commands you would do [command.name for commands in self.client.cogs[cog]]

#

bearing in mind you need the command name not object

manic wing
pine crypt
#

something ... happened?

manic wing
#

noo

#

you need to loop through

#

and do it in the value

#

you still want to loop through the cogs

#

think about it logically

pine crypt
#

cog is not defined

manic wing
#

you want 2 things

#

you want the cog name and the commands in the cog

pine crypt
#

yes

#
[command.name for command in self.client.cogs]```
#

what would be this equivalent in a long list version?

#

that may make more sense to me as to what is going on

manic wing
#

to get the cog name you can iterate through all the cogs the bot has py for cog in self.client.cogs
now you have the name of the cog (cog), you need the commands, correct? so to get the commands you would use cog.walk_commands() where cog is the instance of cog. To get the cog we will do self.client.cogs[cog] which returns the cog instance (self.client.cogs returns a dict with the name being the key, and the cog instance being the value).
to get the commands in the cog it is [command.name for command in self.client.cogs[cog].walk_commands()]
so then it would be ```py
for cog in self.client.cogs:

cog is the name

cog_commands = [command.name for command in self.client.cogs[cog].walk_commands()]

cog_commands is a list of all the commands the cog has

all you have to do now is add the name (cog) and the commands (cog_commands) to the field

manic wing
#

im butchering this explanation

pine crypt
#

i got it

#

not .append(cog) sorry

#

.append(cog_commands)

manic wing
#

cog_commands is already a list

#

thats what list comprehension is

pine crypt
#

ah ok

manic wing
#

no point appending a list to a list

#

instead you want to join the list

#

value = ", ".join(cog_commands)

#

you want to join the list so its a string not a list

#

!join

unkempt canyonBOT
#

Joining Iterables

If you want to display a list (or some other iterable), you can write:

colors = ['red', 'green', 'blue', 'yellow']
output = ""
separator = ", "
for color in colors:
    output += color + separator
print(output)
# Prints 'red, green, blue, yellow, '

However, the separator is still added to the last element, and it is relatively slow.

A better solution is to use str.join.

colors = ['red', 'green', 'blue', 'yellow']
separator = ", "
print(separator.join(colors))
# Prints 'red, green, blue, yellow'

An important thing to note is that you can only str.join strings. For a list of ints,
you must convert each element to a string before joining.

integers = [1, 3, 6, 10, 15]
print(", ".join(str(e) for e in integers))
# Prints '1, 3, 6, 10, 15'
pine crypt
#

thanks

#

This is starting to give errors?

#

this runs successfully

manic wing
#

have you accidentally imported some weird ass module

#

ive never seen that error and i assume you havent done any _closing

naive spoke
#
myEmbed.set_author(name= ctx.user.name)

    await context.message.channel.send(embed=myEmbed)
    
user = ctx.message.author

it says ctx is not defined

manic wing
manic wing
#

huh

pine crypt
#

Let me make your job easier

manic wing
#

oh

#

you've uh

#

do you mean commands.Cog

naive spoke
pine crypt
#

ctx stands for context

naive spoke
#

oh

manic wing
manic wing
#

you havent passed ctx

pine crypt
naive spoke
pine crypt
#
#Imports
from discord.ext import commands
import discord
import json
import os

#Setup
with open ("token.json") as jsonFile:
    jsonObject = json.load(jsonFile)
    jsonFile.close()
TOKEN = jsonObject["TOKEN"]

INTENTS = discord.Intents.default()
client = commands.Bot(
    command_prefix = "!", 
    intents= INTENTS, 
    case_insensitive = False,
    owner_id = 828768915370278972
)
client.remove_command("help")

#Load + Unload
@client.command()
async def load(extension):
    client.load_extension(f"cogs.{extension}")
    
@client.command()
async def unload(extension):
    client.unload_extension(f"cogs.{extension}")

#Run
for filename in os.listdir('./cogs'):
    if filename.endswith(".py"):
        client.load_extension(f"cogs.{filename[:-3]}")

client.run(TOKEN)

My main file (client.py)

manic wing
# pine crypt

on of the field values is empty, meaning a cog might not have any commands

pine crypt
#

yes i have an event cog

naive spoke
#

when i ran it i saw this

manic wing
#

you can do if cog == "event": continue meaning it would skip that loop iteration

pine crypt
#

ye

manic wing
# naive spoke when i ran it i saw this

context.author.name - also I recommend renaming context to ctx - just kinda naming conventions. Also, for set_author(name = context) its context.author.name.
ps you can just do await context.send(embed=myEmbed) and remove the message.channel part

#

remove client = discord.Client()

naive spoke
#

ok

manic wing
#

you have redefined it to commands.Bot

naive spoke
#

yea

wide burrow
#

bro how to fix no module named discord

#

i tried everything

manic wing
pine crypt
#

This shows the same error?

manic wing
#

also you dont need the else

wide burrow
#

it says requirements met

#

already satisfied

manic wing
#

that means you have multiple python versions installed

#

try and figure out which one you use, and uninstall the resrt

pine crypt
manic wing
#

its often python and python3

modest plover
#

Hi, anyone who's good with Disnake, I need help.

My bot won't load cogs, even though I've used bot.load_extensions().

#

It also doesn't throw a traceback error when loading the bot

steep wind
#

how do you do 2 inputs and separate them? so like (command) mcc! bossman fjay but separate bossman and fjay and keep them by themselves

modest plover
#

Ah ok

wide burrow
manic wing
manic wing
modest plover
#

I'll get my files one sec

wide burrow
#

ty

modest plover
#
#main.py
import disnake
from disnake.ext import commands
import os
from decouple import config

token = config('token')

bot = commands.Bot()

@bot.event
async def on_ready():
  print(f"Logged in as {bot.user}.")
  
bot.run(token)
#ping.py
#this is in the folder "commands"
import disnake
from disnake.ext import commands

class Ping(commands.Cog):
    """Pings the bot to see if it can reply to commands correctly."""

    def __init__(self, bot: commands.Bot):
        self.bot = bot

    @commands.command()
    async def ping(self, ctx):
        await ctx.send("Pong!")

def setup(bot):
    bot.add_cog(Ping(bot))
manic wing
manic wing
split plover
#

is there a way with discord.py when the bot tries to send a message with more than 2000 characters or more that it sends it automatically in 2 or more messages?

steep wind
manic wing
steep wind
#

so is it possible to so it with msg.split

#

and also the input can be anything not specfically bossman and fjay

manic wing
modest plover
manic wing
#

.split() automatically splits by whitespace

modest plover
#

Wair

#

Wait*

manic wing
modest plover
#

Why isn't it there-

manic wing
#

lol

modest plover
#

I don't know, one sec

#
#main.py
import disnake
from disnake.ext import commands
import os
from dotenv import load_dotenv

load_dotenv()

token = os.environ["token"]
bot = commands.Bot(test_guilds=[938194100639895713])

bot.load_extensions("commands")

@bot.event
async def on_ready():
    print(f"{bot.user} is loading into developer mode...")

bot.run(token)
#

There

#

It copied my old one

manic wing
#

ah

#

its load_extension not load_extensions

modest plover
#

It uses load_extension__s__()

manic wing
#

wait damn

#

i didnt know that existed

#

thats pretty mad ngl

modest plover
#

I knew it existed, it worked, my bot files got wiped, it broke

manic wing
#

so you have a directory called commands?

#

im not sure if its looking for an __init__.py

modest plover
pine crypt
#

This finds the name but what about if i wanted the description of the command?

manic wing
manic wing
# modest plover

ill take a look at the source code of load_extensions later and see how it works

naive spoke
#

@manic wing so i changed the code but i get this when i run it

manic wing
modest plover
#
def load_extensions(self, path: str) -> None:
        """Loads all extensions in a directory.
        Parameters
        ----------
        path: :class:`str`
            The path to search for extensions
        """
        for extension in disnake.utils.search_directory(path):
            self.load_extension(extension)

#

There

naive spoke
manic wing
#

i think load_extension might be better `

#

this has no check

#

you can do ```py
import os
for cog in os.listdir('commands'):
if not cog.startswith('_'):
bot.load_extension('commands.' + cog[:-3])

#

give this a go

wide burrow
#

newest version for python is 3.10?

manic wing
#

correct

#

not to be confused with python version 3.1

wide burrow
#

ye ty

#

should i add python 3.10 to path?

manic wing
#

yes

#

and remove all the other python versions you have

wide burrow
#

i think i did

#

hope it works now

manic wing
#

windows python is a fuckery

wide burrow
#

true

naive spoke
manic wing
pine crypt
#

Gives the value as all cog_commands in that cog but most of my cogs have only 1 command so how could I make the name have the command and value have command description?

naive spoke
manic wing
#

reset bot token

naive spoke
#

ok

modest plover
#

That also doesn't work @manic wing

#

The /ping command doesn't get registered

wide burrow
#

fk man it didnt work

manic wing
manic wing
#

its not a slash command

modest plover
#

It's supposed to be-

#

have I fucked it up?

manic wing
#

well uh

modest plover
#

Ima take that as a yes.

manic wing
#

not a slash command

modest plover
#

oh.

#

How do I make it a slash command?

manic wing
#

do you know how to make a slash command?

wide burrow
#

still giving requirements already satisfied

modest plover
#

Roughly

#

I did have some at one point but lost it

manic wing
#

familiarize yourself with that directory

manic wing
#

so that should work fine

modest plover
manic wing
#

nice!

modest plover
#

I got it working, thanks Caeden :))

pine crypt
manic wing
modest plover
#

I'm sure of it.

manic wing
modest plover
#

Calling it now, I'll be back in 10 minutes for a dumb as fuck reason.

manic wing
#

you set a cog description like ```py
class cog(commands.Cog):
""" this is the description """

manic wing
manic wing
#

not a problem

modest plover
#

I have one set, but no description pops up

manic wing
# pine crypt

do you want the command description or the cog description?

manic wing
manic wing
modest plover
#
import disnake
from disnake.ext import commands

class Ping(commands.Cog):
    """Pings the bot to see if it can reply to commands correctly."""
#

Mine doesn't have a description even though there's one set

pine crypt
manic wing
pine crypt
#

using """"""

modest plover
#

I have?

manic wing
#

yes, its called a docstring

manic wing
modest plover
#

O

pine crypt
modest plover
#

It is

#

It works for both

manic wing
manic wing
wide burrow
#

ever thought how they programmed a programming language?

modest plover
#

Just in this instance, it's used as a docstring

modest plover
manic wing
#
def func() -> str:
  """
  Returns
  -------
  str
  """
    
  return "hi"
``` this is a docstring
manic wing
slim ibex
#

its what computers can read

pine crypt
slim ibex
#

computers can't read things like what we write

manic wing
#

binary is the lowest form of computer interpreted language, then machine language which is base level shit just under c/c++ - python was made in c or c++, i cant remember

#

!ot

unkempt canyonBOT
pine crypt
#

Computers read programming languages after converting to binary

slim ibex
#

yes, but its not the same as the source code we write. it is machine code that it reads

pine crypt
#
for cog in self.client.cogs:
            if cog == "Ready":
                continue
            cog_commands = [command.name for command in self.client.cogs[cog].walk_commands()]
            helpEmbed.add_field(
                name = cog + self.client.cogs[cog].description,
                value = ", ".join(cog_commands),
                inline = False
            )```
#

Not exactly what I was looking for

manic wing
#

this is my help command

pine crypt
manic wing
modest plover
# manic wing wdym?

I used a docstring to put in a description for the command and it doesn't show said description on the command

pine crypt
manic wing
manic wing
modest plover
#

How come? It looks the same as how you put it?
import disnake
from disnake.ext import commands

class Ping(commands.Cog):
"""Pings the bot to see if it can reply to commands correctly."""

manic wing
modest plover
#

O

manic wing
#

you guys are getting docstrings for cogs and commands mixed up

#

take a second to slow down and think about the logic

cedar stream
modest plover
#

Where would I put the description for the command then?

manic wing
#

as i said, slow down and think about the logic

#

its straight forward...inside the command

cedar stream
manic wing
cedar stream
manic wing
#

to confuse them less and to educate

cedar stream
#

Okok

#

Go ahead

wide burrow
#

should i delete those

manic wing
#
class cog(commands.Cog):
  """ this is the cog description """
  
  @commands.command()
  async def command(ctx): 
    """ this is the command description """
wide burrow
#

foudn them here

manic wing
wide burrow
#

ye thats why i asked

#

idk what r those

manic wing
#

go to settings>uninstall

wide burrow
#

still getting requirements already satisfied issue

manic wing
#

uninstall other python versions

#

dont fuck around with the files themselves or you'll piss off the application

#

application will wonder where the fuck its files have gone and it will throw a tantrum

wide burrow
#

lol alright

#

ty

cedar stream
#

Just delete This PC

manic wing
cedar stream
manic wing
#

remake your pc

wide burrow
#

there is just those

manic wing
#

switch to linux

manic wing
wide burrow
#

ye

manic wing
#

either switch to linux or create a help channel, i dont fuck around with windows enough to help you fix microsofts problems

wide burrow
#

alright

cedar stream
#

Microsoft rly pain in the ass all the time

manic wing
#

if you want you can just sue microsoft and see if they give you some cash to afford linux

pine crypt
manic wing
#

linux is free

pine crypt
cedar stream
#

Word, windows, excel, office365 etc.

#

Nothing works

manic wing
wide burrow
#

@manic wing do u have an idea in which channel they can help me

wide burrow
#

ty

pine crypt
cedar stream
pine crypt
#

Does Help itself need a description?

manic wing
pine crypt
#

Fixed it

manic wing
#

yipee

cedar stream
#

Nice

pine crypt
#

Now for the aesthetics

manic wing
pine crypt
#

lol yes

cedar stream
pine crypt
#
for cog in self.client.cogs:
            if cog == "Ready":
                continue
            cog_commands = [command.name for command in self.client.cogs[cog].walk_commands()]
            helpEmbed.add_field(
                name = cog,
                value = self.client.cogs[cog].description,
                inline = False
            )
        
        await ctx.send(embed = helpEmbed)```

Can I delete cog_commands since it is not in use?
manic wing
#

it might be useful later

cedar stream
#

Comment it out and see if anything breaks

#

If It’ s not used u can get rid of it

#

Mby ur ide alr shows if It’ s being used

pine crypt
cedar stream
#

Then yea u can delete it or comment it out if you will need it later

pine crypt
#

any way to make this automatic instead of listing all cogs incase I have too many later on?

cedar stream
#

Is Ready a name of a cog?

pine crypt
#

class

cedar stream
#

Idk what you are tryna do

placid skiff
#

someone knows a way to go a new line without using "\n"?

cedar stream
placid skiff
#

funny

cedar stream
#

But u need triple wuotes

#

Quotes

placid skiff
#

well i don't know if it works for a bot message

pine crypt
#

it goes through all cogs and if it is named "Ready" it will ignore because ready only contains events not commands therefore cannot be used in help embed. how can i make it so it will instead ignore all cogs that only contain events?

cedar stream
#

Id just use \n honestly except if u got a good reason not to

cedar stream
cedar stream
#

I think I actually did it that way

#

@manic wing help

#

I forgot

manic wing
#

what

pine crypt
# manic wing ?

this requires manual typing. is there a way to check if a cog has a command, if not then ignore it, else add to help

cedar stream
#

The HelpCommand class

#

The one u can inherit from

#

Forgot It’ s name

placid skiff
cedar stream
placid skiff
#

declare a variable and put my string in it

manic wing
#

you can undelete cog_commands

pine crypt
#

i still have it

manic wing
#

and do if not cog_commands: continue

pine crypt
#

so then cog_commands will have to be defined before it instead

manic wing
#

yes

#

wait what

#

where it was defined was fine

manic wing
pine crypt
#

ye

cedar stream
manic wing
#

AVC dont follow this i beg

pine crypt
#

Are these valid functions of ctx?

cedar stream
pine crypt
#

I made a bot 2 years ago and it failed badly

cedar stream
#

U should probably learn oop first

cedar stream
manic wing
pine crypt
#

Nope

cedar stream
#

Oop

#

So u can subclass

pine crypt
#

My parents do automation testing in python

cedar stream
#

They know oop?

pine crypt
#

Which includes OOP

#

Yes

cedar stream
#

U should learn oop

pine crypt
split plover
#

can i somehow hide role specific commands from 'help' command?

manic wing
#

pay your parents to teach you python

#

or get them to pay me

manic wing
#

well depending on your version

cedar stream
cedar stream
split plover
cedar stream
split plover
#

what's that?

cedar stream
#

Object oriented programming

split plover
#

and what should i do with that?

#

i'm not a top tier programmer

cedar stream
cedar stream
split plover
#

ok so how can i hide a command from the help command?

pine crypt
#

Discord has a set character limit but an embed doesn't count as actual text so would an embed be worth 1 character?

cedar stream
manic wing
#

theres a different between content and embed

pliant gulch
#

Base model rewrite looking good so far

manic wing
#

you can have 10 embeds in a message and 2000 characters

pliant gulch
#

10 embeds per message max

manic wing
#

oh 10

manic wing
pliant gulch
#

All model

manic wing
#

whats the model for

pliant gulch
#

I'm rewriting all the models I have in the wrapper

#

The model is just a skeleton class for discord models

#

Making it easier to add them

manic wing
#

andy can you have 10 images and 10 embeds on a file

pliant gulch
#

I don't think there is a limit on files

#

Amount wise*, so as long as its under 8 MiB

#

It would be fine to send

manic wing
#

damn im thinking of how to send the largest message now

#

lots of \ns in the content and embeds, and as many white files as you can fit in

cedar stream
#

Dot*

modest plover
#

There's a limit of 10 attachments at once

#

@manic wing

#

At least there is for normal users, idk about bots

pliant gulch
#

Ah, ok that makes sense

#

Although I don't really see an obvious spot in the docs that say this limit

modest plover
#

Yeah..

#

I knew of the limit purely because I tried to send 20 photos at once

pliant gulch
#

Lmao

#

The documentation for the API could be a lot better

pine crypt
#

Lol I'm not done with my help command yet

#

Time to add buttons and pages

#

Bruh this is gonna take a while

#

How to add buttons?

#

How to add pages?

#

similar to this?

cedar stream
#

U gotta…

#

Subclass

pine crypt
#

ye icba to work any more

#

cya

cedar stream
#

Cya

tacit token
#

Hello! mee6 how did you solve that embed doesn't have a name just value?

#

translate is shit

#

so, how can i make embed similiar MEE6? Mee6 dont use names, use only value.

hoary cargo
#

\u200b

tacit token
#

o ty

tacit token
#

and i how use custom emojis?

#

@hoary cargo

left crater
#

you get the emoji id

hardy wing
#
await (await client.fetch_user(466829347953836033).send('I joined '+guild.name))```
anyone know what I'm doing wrong it's saying it was both never awaited and it's a nil value
hoary cargo
slim ibex
hardy wing
#

I'm just trying to get the bot to dm me when it joins a server

#

someone else gave me that code but it didn't work

sick birch
#

to do it properly you'd have to mess with it even more

#
user = await client.fetch_user(...)
await user.send(...)

Looks much cleaner and would also fix your issue

hardy wing
#

oh alr will try that

sick birch
#

Sometimes when you sacrifice readability and cleanliness you get errors that could've been avoided, so it's always best to keep your code neat and organized so that doesn't happen

slate swan
#

Hey! How to get the object of a user in the server (with a given ID)?

#

I tried guild.get_member(id)
And bot.get_user(id)

#

Both return None

final iron
#

A member object?

slate swan
#

Yes

final iron
slate swan
#

Guess it isnt in the bots cache then, but what about guild.get_member() then?

final iron
#

Same issue

slate swan
#

Oh ok

#

I see so its impossible?

final iron
#

get tries to get it from the bots cache

slate swan
#

I see

#

Could I use fetch?

final iron
#

Yeah

#

!d discord.Guild.fetch_member

unkempt canyonBOT
#

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

Retrieves a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") from a guild ID, and a member ID.

Note

This method is an API call. If you have [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") and member cache enabled, consider [`get_member()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.get_member "discord.Guild.get_member") instead.
slate swan
#

Ah great

#

Thanks

#

Oh and what could I do now to remove a role? Since its now a coro

final iron
#

!d discord.Member.remove_roles

unkempt canyonBOT
#

await remove_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Removes [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s from this member.

You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the removed [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
slate swan
#

I did

user = guild.fetch_member(id)
await user.remove_roles(role)
#

Says that this does not have that attribute

final iron
#

You have to await fetch

slate swan
#

Oh I see lol

sick birch
# slate swan Oh I see lol

Yes, all fetch_* methods are asynchronous considering they make an API request. This is true of most coroutines in discord.py, if it's asynchronous then it's a good bet that it's making an API call. Because of this, it's preferable to stay away from making a direct API call when you can get it from the cache or some other source, since API requests can be slow

hoary cargo
#

also you need member intents

slate swan
#

hm now i wonder if discord.py has any coros for non-api call stuff

#

Yea works now

slate swan
boreal ravine
#

utils.maybe_coroutine is a coro

#

there are lots of coroutines that do non-api stuff

slate swan
#

actually yeah there's a bunch nvm

unkempt canyonBOT
#

discord/channel.py lines 201 to 202

async def _get_channel(self):
    return self```
boreal ravine
#

what?

slate swan
#

because abc.Messageable.send() uses await self._get_channel()

pliant gulch
#

Ok that makes a lot more sense now

slate swan
#

it needs to be asynchronous because User.send() exists

#

hm interesting, Member._get_channel() is its own thing

#

oh ic, because User._get_channel() isn't copied over

pliant gulch
#

Wonder why it isn't copied over though, the API treats Member as a wrapper for User with extra information, and even has a user field inside of the raw data given

slate swan
#

the Member class is decorated with a method that assigns various properties, for example, Member.id is a getter, for Member._user.id

#

so i'm not sure what you mean

#

oh the method isn't copied over because its name starts with _ and the decorator ignores properties that do

pliant gulch
#

You could probably make Member a child class of User

unkempt canyonBOT
#

discord/member.py line 158

def flatten_user(cls):```
pliant gulch
#

Saves some overhead

slate swan
#

creating a full user object per guild member is kind of pointless

#

because a single user can be in multiple guilds, hence having multiple instances of Member associated with them

pliant gulch
#

Isn't there an underlying user anyways for the Member class?

unkempt canyonBOT
#

discord/member.py line 289

self._user: User = state.store_user(data['user'])```
slate swan
#

yes

pliant gulch
#

So, there would be a user for every member either way

#

But yea I do see your other point

slate swan
#

no, _user represents a single instance of User

#

it's not like a User is created every time a Member is created

tacit token
#

How can i make a comma dand send message bot who write the commad only seen it

slate swan
#

it's simply a reference, that's all

mighty apex
#

hiiiiiii

pliant gulch
#

Ah I see ok, but either way if you think about it though, if you created a User then cached it, it would overwrite the previous cache then later the garbage collector would free the memory for the extra user class

#

But yea I see now it's more preformant to not subclass it

slate swan
mighty apex
#

bruh your mom is ugly

rotund frigate
#

trying to make my bot send a message as soon as it gets a message from a specific channel ``` if message.content.startswith('$start_logs'):
if message.channel.find('Bot-Commands'):
channel = client.get_channel(941323760215138324)
await channel.send('s7')

slate swan
#

member._user is simply a reference to that same user

pliant gulch
slate swan
#

still doesn't sound correct

slate swan
slate swan
rotund frigate
#

when i type $start_logs in the bot commands channel, the bot says s7

pliant gulch
# slate swan still doesn't sound correct

How so, if you created a new User class when one exists already, then you cached that, you'd just be getting rid of the old created class, if there is no reference to it the garbage collector will free the memory allocated for it

slate swan
#
if message.channel.find('Bot-Commands'):

this is confusion

rotund frigate
#

idk im new to python and i thot that would work ;-;

#

without that it works if i type start logs in any channel

slate swan
rotund frigate
slate swan
slate swan
#
self._user = state.store_user(data['user'])

this line basically creates a user object if it doesn't exist in cache, caches it, and then returns it
if a cached user exists, it returns that instead, and ignores the data passed to it

rotund frigate
#

i changed it to ```@client.event
async def on_message(message):
if message.channel.startswith('logs'):
if message.content.startswith('$start_log'):
channel = client.get_channel(941323760215138324)
await channel.send('s7')

#

it still didnt work

#

it said the startswith altribute is wrong doesnt work

small igloo
#

google tf

small igloo
balmy ivy
small igloo
balmy ivy
#

it says to many request

small igloo
small igloo
slate swan
#

an 429 means the client has done too many requests

hoary cargo
#

The bot be like let me in

small igloo
small igloo
slate swan
slate swan
#

you can check the apis docs to see the ratelimit

#

so something like this doesnt happend again

worldly oyster
#

i ned help

maiden fable
#

With?

worldly oyster
#

so look

#

i want al of this to reply to my msg

#

this

final iron
unkempt canyonBOT
#

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

A shortcut method to [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") to reply to the [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message").

New in version 1.6.
worldly oyster
#

wont work?

slate swan
worldly oyster
#

show code?

slate swan
#

yes

worldly oyster
slate swan
# worldly oyster

you arent replying to anything it should be

await ctx.reply()

since the Context class has a reply method

worldly oyster
#

i got a error

#

up expect indent

slate swan
#

!indents

unkempt canyonBOT
#

Indentation

Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.

Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.

Example

def foo():
    bar = 'baz'  # indented one level
    if bar == 'baz':
        print('ham')  # indented two levels
    return bar  # indented one level

The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.

Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines

More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation

final iron
#

😔

patent lark
#

if you cant fix indention errors you shouldnt be coding a discord bot.

slate swan
final iron
#

😔

slate swan
final iron
#

You'll be disappointed

slate swan
final iron
#

I haven't even started

slate swan
worldly oyster
patent lark
# worldly oyster

also why do you call the set_footer() function twice? while the first one has the text kwarg with no value passed.

slate swan
worldly oyster
#

okay

patent lark
#

Context.reply() works so much like Context.send(). difference being that it will do a reply to the Context.message which is the message you use to invoke the command.

slate swan
#

!pep8

unkempt canyonBOT
#

PEP 8 is the official style guide for Python. It includes comprehensive guidelines for code formatting, variable naming, and making your code easy to read. Professional Python developers are usually required to follow the guidelines, and will often use code-linters like flake8 to verify that the code they're writing complies with the style guide.

More information:
PEP 8 document
Our PEP 8 song! :notes:

worldly oyster
#

sorry abt tha

patent lark
#

the thing that bothers me most is that they used "client" as their bot object variable.

slate swan
#

nah its fine but you should follow it

patent lark
#

discord.Client() exists, so does the bot object. name your discord.Client() object "client", and the bot object "bot". not the other way around.

woven ingot
#

I have a question maybe someone could help. Im pulling some data from an api and passing it to a variable called totalminted. Then im trying to display that variable in a embed message but I get the variable name instead of what the variable is storing. Im sure im just pluging it in incorrrectly but Im not sure how to make it display the varaiable data.

#
@client.command()
async def cher(ctx):
  embed = discord.Embed(
    title = 'Lorem Ipsum',
    description = "Lorem .",
    colour = discord.Colour.orange()
  )
  embed.add_field(name='Total Nfts Minted', value='totalminted', inline=False)```
slate swan
#

'totalminted' is that really a variable though Thonk

Remove the '' or use {totalminted}

woven ingot
#

Ok that is what I though. Im converting to a string right?

slate swan
#

Correct

woven ingot
#

Thank you!!

lethal urchin
#

does the cooldown decorator work for application commands too?

balmy ivy
#

how do i make it so it mentions the person "godlent"

final iron
unkempt canyonBOT
woven ingot
#

Can you center a string inside an embed so its center aligned?

neat pagoda
#

is anyone willing to prtner with me to build a discord bot? (Coded in Python of course) Dm me if your interested

neat pagoda
worldly oyster
#

didn’t work i took button out shut wont work

neat pagoda
neat pagoda
hardy wing
#
opponent = random.choice(Characters)```
It's saying "set object is not subscriptable" in errors what does that mean
#

Characters is a table of strings only

slate swan
hardy wing
#

oh wait I accidentally used a { instead of a [ mb

slate swan
#

lol

tough trellis
#

how do i see which platform a user is on?

final iron
boreal ravine
#

!d discord.Member.is_on_mobile

unkempt canyonBOT
#

is_on_mobile()```
[`bool`](https://docs.python.org/3/library/functions.html#bool "(in Python v3.9)"): A helper function that determines if a member is active on a mobile device.
boreal ravine
#
def drop_card():
    picture = random.choice(os.listdir("cards/"))
    #file = discord.File("cards/" + picture, filename=picture)
    embed =  discord.Embed(color=discord.Color.blurple())
    embed.set_footer(text="Do $claim <> to claim it!")
    embed.set_image(url="attachment://" + picture)
    return embed
``` the image doesn't get attached
nimble plume
#
embed.add_field(name='Utility', value="afk , userinfo , serverinfo , invites , av , join , leavevc , disconnect", inline=True)
```are these utility commands fine? or i add another category
boreal ravine
#

seems fine

#

don't hardcode a help command tho

nimble plume
#

ok

nimble plume
nimble plume
#

anyone i have a weird red line that says its not closed

final iron
#

Don't hardcode a help command

nimble plume
final iron
#

It means don't hardcode a help command?

nimble plume
#

hardcode?

final iron
#

🚪 🏃‍♂️

nimble plume
#

@final iron i understand now lol

nimble plume
slate swan
unkempt canyonBOT
#

property commands: Set[discord.ext.commands.core.Command[discord.ext.commands.core.CogT, Any, Any]]```
A unique set of commands without aliases that are registered.
nimble plume
#
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Commands' object has no attribute 'me'
#

newly added cogs

slate swan
nimble plume
#

..

quick gust
#

I wanna wait for 2 possible texts from a user, (yes or no). I was thinking of using wait_for but I have no idea how I would do something if they say "yes" and do something else if they say "no"

nimble plume
slate swan
#

for example:

message = await client.wait_for('message')

if message.content == 'yes':
  ...
elif message.content == 'no':
  ...
#

this example is very basic and very prone to bad user input btw

slate swan
quick gust
slate swan
#

Just use a check

quick gust
#

yeah but I have 2 different conditions

#

do something if yes, do something else if no

#

i didn't understand how I would implement checks with that

slate swan
#
def check(msg):
   return msg.content in ("yes","no") and msg.author == user
    ```
#

Its slightly wrong but i hope u get it

#

msg author should be msg.author

nimble plume
# slate swan then show your code, we don't read minds around here
class Commands(commands.Cog):
    """huh?."""
    def __init__(self, bot: commands.Bot):
        self.bot = bot
    @commands.guild_only()
    @commands.command(name="kick")
    # @commands.has_permissions(kick_members=True)
    async def kick(ctx, user: discord.Member=None, * , reason=None):
     if ctx.me.guild_permissions.kick_members is not True:
       s = discord.Embed(description="I dont have kick perms",color=red,timestamp=datetime.utcnow())
       await ctx.reply(embed=s)
     elif user is None:
        s = discord.Embed(title="Define the member",color=red,timestamp=datetime.utcnow())
        await ctx.reply(embed=s)
     elif ctx.author.top_role <= user.top_role:
           s = discord.Embed(description=f"{user} |  Is Mod/Admin cannot kick",color=red,timestamp=datetime.utcnow())
           await ctx.reply(embed=s)
     elif user.top_role >= ctx.me.top_role or user.guild_permissions.administrator:
           s = discord.Embed(description="The user has bigger role than me cannot kick",color=red,timestamp=datetime.utcnow())
           await ctx.reply(embed=s)
     else:
          lol = discord.Embed(title=f"You are Kicked from {ctx.message.guild.name}", description=f"**Reason**: {reason}", color=aqua,timestamp=datetime.utcnow())
          await user.send(embed=lol)
          await user.kick(reason=reason)
          kick = discord.Embed(title=f"Kicked {user}", description=f"**Reason**: {reason}", color=green,timestamp=datetime.utcnow())
          kick.set_footer(text=f"Requested by {ctx.author}", icon_url=f"{ctx.author.avatar_url}")
          await ctx.reply(embed=kick)
                    

    








def setup(bot: commands.Bot):
    bot.add_cog(Commands(bot))
quick gust
quick gust
#

let me give an example, say I'm selling all my items.
I want the bot to send a confirmation message. If I reply with yes, it will sell it, or else it won't sell it. Now I just don't know how to integrate it with checks because if the check fails it doesn't even raise an error I think

slate swan
#

the check should just return a truthy or falsey value.

#

usually the check is put in place to make sure the channel and author are the same for both messages, any other logic is usually put after the message is received

quick gust
#

Yeah I think that's what I'll do

#

I'll give it a try, thanks for your help

slate swan
#

i've seen a lot of people who've unfortunately forgotten about while loops and have a big ass chain of wait_for, or they just stop the back and forth exchange when the end user makes an error

slate swan
#
try:
  msg = await wait_for()
except TimoutError:
  return await send('timed out')

...

try:
  msg = await wait_for()
except TimoutError:
  return await send('timed out electric boogaloo')


# or

msg = await wait_for()

if condition(msg):
  msg = await wait_for()
  if condition(msg):
    msg = await wait_for()
    ...
  else:
    return await send('try again')
else:
  return await send('try again')

avoid this

slate swan
slate swan
#

first parameter has to be self, ctx and other parameters follow after that.

nimble plume
#

thanks

quasi stag
#

how do i know what permissions does the user need on a missingpermissions error

slate swan
#

!d discord.ext.commands.MissingPermissions.missing_permissions

unkempt canyonBOT
quasi stag
#

thanks

cloud mason
#

cool

slate swan
#

me

boreal ravine
#
def drop_card():
    picture = random.choice(os.listdir("cards/"))
    file = discord.File("cards/" + picture, filename=picture)
    embed =  discord.Embed(color=discord.Color.blurple())
    embed.set_footer(text="Do $claim <> to claim it!")
    embed.set_image(url="attachment://" + picture)
    return embed #i send it using await send(embed=drop_card())
``` image doesn't get attached
slate swan
unkempt canyonBOT
#
Naw.

No documentation found for the requested symbol.

nimble plume
#

file=file

boreal ravine
#

guys

#

go to #bot-commands stop spamming ffs

slate swan
#

discord.

#

what is this command for

nimble plume
#

lol

slate swan
#

!d discord.abc.Messageable.send

unkempt canyonBOT
#

await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=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.9)") 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.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
nimble plume
slate swan
#

oh

boreal ravine
slate swan
boreal ravine
#

that sends a file

slate swan
#

doesn't seems so

nimble plume
boreal ravine
#

no? i don't wanna send the file

#

i just wanna send the embed with the file as it's image

nimble plume
slate swan
#

he wants to attach a img in a embed

nimble plume
slate swan
#

How do you suppose it to get added in the embed then?

boreal ravine
slate swan
#

!local-file

unkempt canyonBOT
#

Thanks to discord.py, sending local files as embed images is simple. You have to create an instance of discord.File class:

# When you know the file exact path, you can pass it.
file = discord.File("/this/is/path/to/my/file.png", filename="file.png")

# When you have the file-like object, then you can pass this instead path.
with open("/this/is/path/to/my/file.png", "rb") as f:
    file = discord.File(f)

When using the file-like object, you have to open it in rb mode. Also, in this case, passing filename to it is not necessary.
Please note that filename can't contain underscores. This is a Discord limitation.

discord.Embed instances have a set_image method which can be used to set an attachment as an image:

embed = discord.Embed()
# Set other fields
embed.set_image(url="attachment://file.png")  # Filename here must be exactly same as attachment filename.

After this, you can send an embed with an attachment to Discord:

await channel.send(file=file, embed=embed)

This example uses discord.TextChannel for sending, but any instance of discord.abc.Messageable can be used for sending.

slate swan
#

Read this.

boreal ravine
#

thats what i did mate

nimble plume
slate swan
#

last part?

boreal ravine
#

this sends a file

slate swan
#

No wtf

nimble plume
#

lol

slate swan
#

Read the full message.

nimble plume
#
ctx.send(embed=embedname)
slate swan
#

Or atleast the first linem

boreal ravine
nimble plume
boreal ravine
#

thats what i did

nimble plume
nimble plume
#

any help now?

boreal ravine
#

no

nimble plume
#

great

boreal ravine
#

i did it earlier, the file got sent by itself and not inside the emebd

slate swan
# boreal ravine

Why do you expect random.choice to be same for both the command /event which you use to send the choice and the drop_card function

nimble plume
#

suggestions

boreal ravine
#

i only use it inside the function

nimble plume
#

ok

slate swan
#

and how do you send the file then?

boreal ravine
#

await message.channel.send(file=file, embed=embed) the output is the ss i sent earlier

nimble plume
#

🤨

unkempt canyonBOT
#

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

len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.

bool(b) Returns whether the embed has any data set.

New in version 2.0.

Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then a special sentinel value is returned, [`Embed.Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty").

For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") for you.
slate swan
boreal ravine
slate swan
#

But you returned only embed

nimble plume
#

😵‍💫

boreal ravine
#

i returned the file and embed in the old one

#

nvm guys i'm using disnake again because it has a file kwarg in set_image sorry for wasting your time

slate swan
#

lol

nimble plume
#
bot.voice_clients
#

bot is not defined i just shifted to cogs

#
class Commands(commands.Cog):
    """huh2?."""
    def __init__(self, bot: commands.Bot):
        self.bot = bot
```in the class
slate swan
#

self.bot

boreal ravine
#

dude

#

use your class attribute

#

you define it but you don't use it??

slate swan
#

^

nimble plume
slate swan
#

your class has a bot attr use it

boreal ravine
#

self.bot

nimble plume
#

self.

nimble plume
#

lol

#
Commands.bot.voice_clients
slate swan
#

no

nimble plume
#

somhow i cant use it

slate swan
#

self.bot.voice_clients

nimble plume
obsidian zodiac
#

i need a team to make a movie streaming website

slate swan
#

how is that not working

nimble plume
#

capital S?

nimble plume
slate swan
nimble plume
#

btw ```py
voice = discord.utils.get(self.bot.voice_clients, guild=ctx.guild)

nimble plume
#

self is not definer

#

wait lemee check indentation

slate swan
#

thats the problem lol

fresh iron
#

enough of python let's talk about pyutin

slate swan
#

if its not defined its not in the class

nimble plume
#

how to make font small in vs code

#

for ss

fresh iron
#

ctrl -

slate swan
cedar stream
fresh iron
#

innit press control and minus

nimble plume
slate swan
#

I use the mouse scroll+key combination

nimble plume
slate swan
#

or just dont ss and just

#

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

So only the code, and not the complete ui gets zoomed out

cedar stream
nimble plume
fresh iron
#

self isn't defined

nimble plume
#

hec

nimble plume
nimble plume
cedar stream
nimble plume
#

how do i fix??

#

what is problem

cedar stream
#

Add self argument

#

Ur inside a class

nimble plume
nimble plume
cedar stream
#

Methods inside a class usually have 1st argument as self argument

#

Learn oop

fresh iron
#

did you my dude write all of that but don't know how to add self argument

fresh iron
#

🤨

cedar stream
#

nimble plume
#

ok lol i get it

#

i didnt add self in function

#

lol

fresh iron
#

oh congrats

nimble plume
#

😅

cedar stream
#

🎉

nimble plume
#

silly mistake

fresh iron
#

that's what i literally said though

nimble plume
#

lol

#

i was changin to cogs

#

so i forgot

#

working fine now

cedar stream
#

So it looks nicer

fresh iron
#

na effort

nimble plume
#

done

fresh iron
#

hope you didn't mess up ur code

nimble plume
#

okk

cedar stream
nimble plume
#

😅

vale wing
#

How to remove all the components from a message in disnake? Thought about editing it with empty view but is this correct

quick gust
#

u can remove_item too

red sundial
#

i have a hex code inside a string, how do i make it hexadecimal so that i can pass it to the embed colour

brazen raft
#

Use int with base 16

slate swan
#

Like this right?

maiden fable
#

No?

red sundial
#

then how

maiden fable
#

!e print(int("10", 16))

slate swan
#

that's definately not what I did

unkempt canyonBOT
#

@maiden fable :white_check_mark: Your eval job has completed with return code 0.

16
slate swan
#

!e print(int("ffffff",16))

unkempt canyonBOT
#

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

16777215
red sundial
#

oh

brazen raft
#

How does the string you're getting look

maiden fable
#

Ah

red sundial
#

#ffffff

#

like that

slate swan
#

just strip. # from that

brazen raft
#

Strip off the hashtag symbol and use int as demonstrated

red sundial
#

lemme try that thank you

#

nice it works

#

thanks so much!

brazen raft
#

👍

halcyon bison
#

is it possible to send messages every day at a specific time in my timezone

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").
halcyon bison
#

no i dont mean like that

slate swan
#

Use this with 1 second loop

#

and you can compare your timezone's time using datetime module

halcyon bison
#

i tried that but i cant calculate it properly so can i do 4:00pm or something like that

slate swan
#

!e import datetime
print(str(datetime.datetime.now()))

maiden fable
#

Lmao

slate swan
#

Compare it with this format

unkempt canyonBOT
#

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

2022-02-14 08:08:56.566757
halcyon bison
slate swan
#

0-12 is am, 12-23 is pm

halcyon bison
#

oh

#

ohhhhh

halcyon bison
#

but wait i'll have to change 2022-02-14 every day

slate swan
#

you can just use the time part of that

halcyon bison
#

yeah but if i do wont the 2022-month-day be included

brittle axle
#

I am making music functionality to my bot and there is a problem with the play commands. Everytime i play a song the youtube_dl works perfectly the bot join the voice channel but an error named FFmpegPCMAudio has no attribute _proccess

#

Here is the code

slate swan
#

!ytdl

unkempt canyonBOT
#

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

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

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

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

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

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

oh ok

#

But where can i get help on that??

brittle axle
#

not youtube_dl

#

I cant ask about that too?

#

or nvm

#

that also break rule 5

slate swan
#

Bot can connect to the call, but it won't send the chat and won't play the audio. What should I do?

    else:
        if x < 2.5:
            word = random.randint(1,2)
            if message.author.bot:
                return
            if word == 1:
                await message.author.voice.channel.connect()
                await message.send("test1")
                await message.guild.voice_client.play(discord.FFmpegPCMAudio("example_01.mp3"))
                await message.guild.voice_client.disconnect()
            if word == 2:
                await message.author.voice.channel.connect()
                await message.send("test2")
                await message.guild.voice_client.play(discord.FFmpegPCMAudio("example_02.mp3"))
                await message.guild.voice_client.disconnect()
boreal ravine
#

message.channel*

#

you cannot send something to a message

nimble plume
#

lol

nimble plume
#

help

#

im getting error

#
  File "C:\Users\hp\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\bot.py", line 608, in _load_from_module_spec
    del sys.modules[key]
KeyError: 'utility'
#
bot.load_extension("utility")
maiden fable
#

Seems like the bot can't find a file with name utility

nimble plume
#

@maiden fable

oblique adder
#

what does ctx.voice_client return ?

#

does it return member vc or bot vc ?

#

does
ctx.voice_client
same as
guild.voice_client and member.guild.voice_client

vocal snow
#

It returns an instance of discord.VoiceClient for that guild

tacit token
#

hello guys, how can i make command "only you can see this"

slate swan
#

ephemeral responses which can be generated only through interactions

supple thorn
#

How do i check for line breaks again

#

Like
These
Breaks

serene mantle
#

Hey guys, im trying to host my bot on Pebblehost and im getting this
disnake.ext.commands.errors.ExtensionFailed: Extension 'cogs.verfication' raised an error: ImportError: cannot import name 'NoneType' from 'types' (/usr/lib/python3.9/types.py)

#

the error isn't present on my main PC

#

and ive also imported "types

maiden fable
serene lynx
#

how to enable pyenv shell on manjaro?

steady berry
#

If somebody can code bot what will download every picture what is send it would help me

oblique adder
#

How do I check if the bot is in the same voice channel as the ctx.author ?

maiden fable
#

It tells u haha

serene mantle
steady berry
#

can somebody code discord bots in python

maiden fable
#

!d discord.Message.attachments

unkempt canyonBOT
maiden fable
#

!d discord.Attachment

unkempt canyonBOT
#

class discord.Attachment```
Represents an attachment from Discord.

str(x) Returns the URL of the attachment.

x == y Checks if the attachment is equal to another attachment.

x != y Checks if the attachment is not equal to another attachment.

hash(x) Returns the hash of the attachment.

Changed in version 1.7: Attachment can now be casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") and is hashable.
steady berry
serene mantle
#

yes it can

steady berry
#

oh ok

maiden fable
#

!d discord.Attachment.save

unkempt canyonBOT
#

await save(fp, *, seek_begin=True, use_cached=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Saves this attachment into a file-like object.
serene mantle
#

what he said ^