#discord-bots

1 messages Β· Page 522 of 1

umbral carbon
#

πŸ˜”

ionic path
#

but you can check it if you want lol

umbral carbon
#

Are you currently working on a project

ionic path
#

kind of

umbral carbon
#

Oh whats it about

ionic path
#

bot for a discord server

umbral carbon
#

What kind of bot

ionic path
#

MEE6 + Dank Memer

umbral carbon
#

Oh cool

#

I like both of them πŸ˜‚

ionic path
#

But the name is not like exactly that

umbral carbon
#

Whats its name

ionic path
#

Manana Bot

#

its for my server

#

btw do yuo want me to do something rad @umbral carbon ?

#

@ashen notch What is the max int limit in python expressed like this (1e+1)

#

kind of like this 1.346778e+34575

void dew
#

I need help I have already asked question

umbral carbon
ionic path
#

(though he didn't respond ;-;)

umbral carbon
#

Do you earn through your bots

ionic path
#

no

#

but ngl its fun

#

and its a learning exp

#

and the skill sometimes pay off for some projects

umbral carbon
#

Hmm Im new with bots and its fun but my laptop broke 2 days ago

#

Waiting for a response from the support

ionic path
umbral carbon
#

So when i try yo turn it on with adapter connected its power button blinks and it doesnt turn on

ionic path
umbral carbon
#

πŸ˜‚πŸ˜‚

ionic path
#

πŸ˜‚

umbral carbon
#

I was just sharing the issue

ionic path
#

why do people ask programmers to fix their electronics tho πŸ€”

#

like its literally on the name its electronics for electricians

#

what's with people's brains these days

slate swan
#
@client.command()
@commands.has_permissions(administrator=True)
async def munban(ctx):
    banned_users = await ctx.guild.bans()

    for user in banned_users:
        await ctx.guild.unban(user.id)
    await ctx.send("Unbanned everyone.")

Thats my code ^

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'BanEntry' object has no attribute 'id'

Thats my error^

I am trying to unban everyone

ionic path
#

I think it is because alot of programmers being smart with computer

#

but it doesn't nececarilly mean that they're also smart with everything

crystal wind
#

Is it possible to have a bot interaction response without a button clicked?

slate swan
waxen granite
#
    async def on_message(self, message):
        msg = message.content.lower()
        localdate = datetime.date.today()
        obgend = datetime.date(2021, 11, 13)
        surgeryend = datetime.date(2022, 1, 12)
        medicineend = datetime.date(2022, 3, 13)
        cmend = datetime.date(2022, 5, 12)
        electivesend = datetime.date(2022, 5, 27)
        casualtyend = datetime.date(2022, 6, 11)
        ophthalend = datetime.date(2022, 6, 26)
        entend = datetime.date(2022, 7, 11)
        orthoend =datetime.date(2022, 8, 10)
        pediatricsend = datetime.date(2022, 9, 14)
        if msg == "posting":
            if localdate < obgend:
                def obg(localdate, obgend):
                   return (localdate - obgend).days
                days = f"{obg(obgend, localdate)}"
                print(days)
                if days == 1:
                    await message.reply("Your Next posting `Surgery`, starts tomorrow.")
                else:
                    await message.reply(f"Current Posting: `OBG`, {days} days to go.")```
Yesterday too it was showing 38days to go and today as well. Is something wrong?
ionic path
#

^^

slate swan
#

Oh

ionic path
#

you used id in user

#

its supposed to be a member object

slate swan
#

ahh

ionic path
#

but you can use discord.utils.get to get the member object with just the id

slate swan
ionic path
#

huh..

#

oh wait......

#

await user.unban() πŸ€¦β€β™‚οΈ

#

breh

slate swan
#

hm

#
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'BanEntry' object has no attribute 'unban'
ionic path
#

what

slate swan
#
@client.command()
@commands.has_permissions(administrator=True)
async def munban(ctx):
    banned_users = await ctx.guild.bans()

    for user in banned_users:
        await user.unban()
    await ctx.send("Unbanned everyone.")
ionic path
#

hmm........................................

#

I think its in rewrite so maybe await ctx.guild.unban(user)?

#

I just removed the id

slate swan
#

I tried that too

#
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'BanEntry' object has no attribute 'id'
ionic path
#

not a user/member object

slate swan
ionic path
#

I found a way to get all banned members

void dew
#

I need help. Someone help me

ionic path
#

banned_users = await client.get_bans(ctx.guild)

ionic path
void dew
ionic path
#

where

slate swan
ionic path
#

nice

void dew
#

Here @ionic path

ionic path
#

where is the code to the aki command

void dew
ionic path
#

what the...

boreal ravine
ionic path
#

ohh

#

ak not defined

#

try doing aki instead of ak

void dew
gloomy coral
#

Why is this happening?

#
    @commands.command()
    async def akinator(self,ctx):
        await ctx.send(embed=discord.Embed(title="Akinator is here to guess!",description="'Y' is Yes, 'N' is No, 'P' is Probably, 'B' is Back",color=discord.Color.random()))
        def check(msg):
            return msg.author == ctx.author and msg.channel == ctx.channel and msg.content.lower() in ["y", "n","p","b"]
        try:
            aki = akinator.Akinator()
            q = aki.start_game()
            while aki.progression <= 80:
                await ctx.send(embed=discord.Embed(title=q,description="Your answer:(y/n/p/b)",color=discord.Color.random()))
                msg = await self.bot.wait_for("message", check=check)   
                if msg.content.lower() == "b":
                    try:
                        q=aki.back()
                    except akinator.CantGoBackAnyFurther:
                        await ctx.send(discord.embed(title=e,color=discord.Color.random()))
                        continue
                else:
                    try:
                        q = aki.answer(msg.content.lower())
                    except akinator.InvalidAnswerError as e:
                        await ctx.send(discord.embed(title=e,color=discord.Color.random()))
                        continue
            aki.win()
            await ctx.send(embed=discord.Embed(title=f"It's {aki.first_guess['name']} ({aki.first_guess['description']})! Was I correct?(y/n)\n{aki.first_guess['absolute_picture_path']}\n\t",color=discord.Color.random()))
            correct = await self.bot.wait_for("message", check=check)
            if correct.content.lower() == "y":
                await ctx.send(embed=discord.Embed(title="Yay\n",color=discord.Color.random()))
            else:
                await ctx.send(embed=discord.Embed(title="OOF\n",color=discord.Color.random()))
        except Exception as e:
            await ctx.send(e)```
ionic path
void dew
ionic path
#

idk aki api

#

maybe replace all ak with aki

#

using replace all in vscode

void dew
ionic path
#

sure

#

.help

outer violet
#

How do I make a random colored embed have the same random color as another embed like this?

unkempt canyonBOT
#

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

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

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

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

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

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

visual island
#

put the random color value to a botvar

unique breach
#

guys

#

why does my discord bot keep saying this interaction failed in buttons even tho it works

slate swan
#

How could I create temp roles

waxen granite
#

datetime.date.today() gets the date from what timezone by default?

slate swan
#

UTC

waxen granite
#

Huh

#

Thats wierd then

errant abyss
#

how do i print the username without mentioning them?

errant abyss
slate swan
#

That might also add the #7373

errant abyss
#

i don't wanna print the number

#

just the username

errant abyss
waxen granite
slate swan
#

Show the command your using it in

errant abyss
# waxen granite Show code
import discord
from discord.ext import commands
import base64


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


token = read_token()

bot = discord.ext.commands.Bot(command_prefix = '.')


@bot.command()
async def b64(ctx, task, string):
    if task == 'encode':
        stringBytes = string.encode("ascii")

        b64Bytes = base64.b64encode(stringBytes)
        b64String = b64Bytes.decode("ascii")

        embed = discord.Embed(title = f"Encoded string for {user.name}")


bot.run(token)```
#

lemme try'

#

thanks works now

waxen granite
#

Ctx.author

slate swan
#

Also I wouldn't use discord import

slate swan
waxen granite
#

Ok

#

No competition here tho

slate swan
#

But he already got the answer

waxen granite
#

Cool

slate swan
#

I'll check out your bot

errant abyss
#

hey how do i print the nickname for a user?

#

instead of username with the # tag

#

@slate swan @waxen granite

waxen granite
#

It prints the nickname only in the ctx

#

I think

errant abyss
#

yeah i'm using ctx

#

how do i print it?

waxen granite
#

I mean the last code prints the nickname only

errant abyss
#

nah it printed my username with the # tag

waxen granite
#

Not sure tho

#

Change your name in the guild and try

errant abyss
#

lemme try

#

it's printing the same, but without the # tag

waxen granite
#

Use the .nick

errant abyss
#

where?

#

where exactly?

waxen granite
#

ctx.author.nick

errant abyss
#

lemme try

#

oh yeah thanks Endomorph

#

ctx is dope

waxen granite
#

Np

errant abyss
#

i have a command that takes 2 arguments

#

in case someone enters a third argument by mistake/accidentally enters a space, how do i print a error message for that?

dapper cobalt
errant abyss
#

ok cool

#

i got a huge error

#

my command takes 2 arguments: .b64 encode/decode string

#

now i want to print a list of commands when the user types '.b64 help'

#

but i get an error that says 'string' argument is missing

#

how do is solve this?

valid perch
#

Can we see the command def

errant abyss
#

it's there

#

thanks @valid perch

valid perch
#

πŸ‘

#

Dont forget the other stuff I saidd

errant abyss
#

yeah sure

#

how do i turn the circled part to green color?

#

there's a thick black line right...

#

can i turn that to green?

valid perch
#

Thats it anyway

#

!d discord.Embed.colour

unkempt canyonBOT
#

The colour code of the embed. Aliased to color as well. This can be set during initialisation.

errant abyss
#

color or colour?

#

colour

#

aight

#

where do i add it in the code?

#

i typed it inside the embed def, and i got like 5 errors

valid perch
#

Embed(colour=...)

errant abyss
#

aight

#

i add in green with the hex code right?

#

#00FF00

#

like this?

valid perch
#

Try it and see

maiden fable
#

!d discord.Colour.green

unkempt canyonBOT
#

classmethod green()```
A factory method that returns a [`Colour`](https://discordpy.readthedocs.io/en/master/api.html#discord.Colour "discord.Colour") with a value of `0x2ecc71`.
errant abyss
maiden fable
#

(:

errant abyss
#

and it's my first ever Python project!! 😊

ocean leaf
#

i am getting this error. please help me

#
@client.command()
@commands.has_role('▄︻デgiveawaysֆ══━一')
async def gcreate(ctx, time = None, *, prize = None):
  if time == None:
    return await ctx.send('Please include a time!')
  elif prize == None:
    return await ctx.send('Please include a prize!')
  
  embed = discord.Embed(
    title = 'Giveaway!',
    description = f'{ctx.author.mention} is giving away **{prize}**!'
  )

  time_convert = {'s':1, 'm':60, 'h':3600, 'd':86400}

  gawtime = int(time[0]) * time_convert[time[-1]]

  embed.set_footer(text = f'Giveaway ends in {time}')

  gaw_msg = await ctx.send(embed = embed)
  await gaw_msg.add_reaction("πŸŽ‰")

  await asyncio.sleep(gawtime)

  new_gaw_msg = await ctx.channel.fetch_message(gaw_msg.id)

  users = await new_gaw_msg.reactions[0].users().flatten()

  users.pop(users.index(client.user))

  winner = random.choice(users)
  await ctx.send(f'Congratulations! {winner.mention} won {prize}!')
#

here is my code

#

pls help

errant abyss
#

hey, i'm on Heroku trying to run my bot

ocean leaf
#

pls help me

ocean leaf
errant abyss
errant abyss
#

i'm just a noob

ocean leaf
#

ok np

ocean leaf
ocean leaf
errant abyss
#

so no 'install'?

ocean leaf
errant abyss
#

aight tysm

ocean leaf
#

no need of pip install

ocean leaf
ocean leaf
vale glen
#

Alright ill try my best

ocean leaf
#

ok pls

errant abyss
#

pycharm

slate swan
errant abyss
#

i'm following Tech With Tim on YT

#

i'm doing what he's doing

slate swan
#

do pip freeze so you'll get all requirements

errant abyss
#

but his way of installing discord.py Rewrite didn't work for me

ocean leaf
#

i highly recomend u to write ur own code

errant abyss
slate swan
ocean leaf
vale glen
ocean leaf
#

yes

ocean leaf
slate swan
slate swan
ocean leaf
#

anyone does?

#

wait i ama go to dpy official dc server

errant abyss
#

like unfreeze or anything lol

slate swan
errant abyss
#

aight cool

slate swan
#

just copy that and paste and u r good to go

unkempt canyonBOT
#

Hey @errant abyss!

Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:

β€’ If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)

β€’ If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:

https://paste.pythondiscord.com

errant abyss
slate swan
#

save and send the link

errant abyss
slate swan
errant abyss
#

oh ok

slate swan
#

pycharm or cmd prompt?

errant abyss
#

cmd

slate swan
#

hm ok

errant abyss
#

i went to the dir where i had my bot files and did cmd

slate swan
errant abyss
#

oh

#

lemme try

slate swan
#

ok

errant abyss
#

i did too

#

maybe its cuz i used anaconda for this

slate swan
#

oh

errant abyss
#

??

slate swan
errant abyss
#

oh ok

#

help me out, i got this error

#

@slate swan

dusk pumice
#

What event happens when someone boosts the server?
Plz help me

vocal plover
#

member update

dusk pumice
#

Hmm

dusk pumice
#

How can I use it

vocal plover
#

check if the member before doesnt have the booster role and the member after does

dusk pumice
#

Hmm.. C- c- can you send me any sample code?

#

Umm... If you don't want to you don't have to.

vocal plover
#
@bot.listen()
async def on_member_update(before, after):
  if before.guild.premium_subscriber_role not in before.roles and before.guild.premium_subscriber_role in after.roles:
    # The member just boosted
dusk pumice
#

Ohh!! Thank you..

#

So @bot.command()was worng. It was !bot.listen()

dusk pumice
sweet pilot
dusk pumice
#

How do I set premium subscriber role???

vocal plover
#

you cant

#

its an attribute of the guild that discord defines

dusk pumice
#

Ok.

#

Than I don't have to set the role?

vocal plover
#

nope

sweet pilot
#

you don't need to

elfin quest
#

hello

dusk pumice
#

Ok%%

sweet pilot
#

it defaults to server booster role

dusk pumice
#

Kk thanks

elfin quest
#

@sweet pilot

dusk pumice
elfin quest
#

<@&267628507062992896>

#

<@&831776746206265384>

dusk pumice
#

Hey?

elfin quest
#

@unkempt canyon

dusk pumice
#

Stop ping

sweet pilot
elfin quest
#

my name is @elfin quest

arctic python
#

Hello, do you need moderation assistance?

dusk pumice
unkempt canyonBOT
dusk pumice
arctic python
#

@elfin quest Do you?

dusk pumice
#

Why you pinged mods?

elfin quest
#

yes

arctic python
#

What do you need?

dusk pumice
#

Kinde mods

sweet pilot
arctic python
sweet pilot
#

idk, his profile says so

#

when you click on him

dusk pumice
#

Well it maybe

#

but it's not good to ping mods with little problems

sweet pilot
dusk pumice
#

Haha I also see his profile

sweet pilot
#

I mean unnessary pings

arctic python
#

@elfin quest Only ping moderators if you need help with someone breaking the rules or code of conduct of the server. If you need help with Python, you can ask in #python-discussion or one of the topical channels, or you can check out #β“ο½œhow-to-get-help.

dusk pumice
sweet pilot
#

maybe it's an alt account used to spam servers

#

dk for sure

arctic python
#

Pinging moderators is fine if you actually need a moderator. That's why the role is pingable.

dusk pumice
arctic python
#

But we have a lot to do, so we prefer if you don't waste our time unnecessarily.

dusk pumice
#

Kind mods

amber imp
#
        users = await new_gaw_msg.reactions[0].users().flatten()

        users.pop(users.index(bot.user))

        winner = random.choice(users)
        await ctx.send(f'Congratulations! {winner.mention} won {prize}!')
```how do i use this in cogs?
amber imp
lament mesa
#

self.bot.user

amber imp
#

ok

dusk pumice
#

I should use cogs too

amber imp
dusk pumice
#

^^

#

I got to go now~~ Cy

#

a

dusk pumice
#

goooooooood

amber imp
dusk pumice
#

πŸ™‚

errant abyss
#

hey is there any way to make my repo public and only my token file private?

reef shell
#

use gitignore

errant abyss
#

how?

#

where do i place gitignore?

errant abyss
#

ahhh man made a bot now it says it's offline

#

i don't have an 'on_ready()' function in my code. is that the problem?

unreal silo
#

no

errant abyss
#

then why's it offline?

#

yall got any common error fixes?

#

client.login() maybe? i don't have that either

boreal ravine
errant abyss
#

lemme check with my tokens and stuff

boreal ravine
#

Yes, client.run("YOUR_TOKEN")

errant abyss
#

i fixed my token issue. now the bot's online but my commands ain't working 😭😭

#

now it's back offline

unreal silo
#

follow the tutorial properly, cba to get into this

errant abyss
#

should i try repl.it instead of Heroku?

maiden fable
errant abyss
#

oh

#

imma try turning on automatic deploys on Heroku

#

oh, ok, now it works

#

i had to change my token in my repo

haughty sedge
#

hi if my bot is running from one place and i re-generate a token will my bot be stopped from there? if yes then amazing else F

errant abyss
#

but auto deploy was turned off in Heroku

#

now i turned it on, now works well

haughty sedge
#

alright thanks

boreal ravine
#

can tasks.loop have parameters?

slate swan
#

just use loop.create_task if you want some parameters to be passed

boreal ravine
#

hm

boreal ravine
valid niche
slate swan
boreal ravine
#

hm

valid niche
#

all about the loop

slate swan
#

keep in mind just use an infinite loop if you want it to persist

valid niche
#

make your async function a while True or similar

boreal ravine
boreal ravine
#

does the lib support cog support for that yet?

slate swan
#

hello,
so I am using github repo to host my bot
and i have a bot which plays sound files the thing is that the sound files are just on the repo and I was them to be in a folder named sound but when I put the files in sound its showing out of directory so how do I add the directory in my codes of sound folder these are the codes

#
@bot.command()
async def test(ctx: commands.Context):
    voice_channel: discord.VoiceChannel = ctx.author.voice.channel
    print(voice_channel.name)
    vc = await voice_channel.connect()
    vc.play(discord.FFmpegPCMAudio("sound.mp3"))
    while vc.is_playing():
        time.sleep(.1)
    await vc.disconnect()```
grim oar
#

Have you tried putting its full path

slate swan
#

like even if I get it know where to enter

#

its like bot/main.py

grim oar
#

Uhh just copy the path and paste it in FFmpegPCMAudio?

slate swan
grim oar
#

Sure ig

slate swan
#

alr

boreal ravine
#

How do you host a bot on github?

slate swan
#

can you?

visual island
#

no

boreal ravine
#

^

slate swan
slate swan
final iron
#

Theres a lot of reasons why you shouldn't host on repl.it

supple thorn
final iron
# gloomy quest like?

You should not use Repl.it to host your bot.

While this may seem like a nice and free service, it has a lot more caveats than you might think, such as:

  • The machines are super underpowered.

    • This means your bot will lag a lot as it gets bigger.
  • You need to run a webserver alongside your bot to prevent it from being shut off.

    • This isn't a trivial task, and eats more of the machines power.
  • Repl.it uses an ephemeral file system.

    • This means any file you saved via your bot will be overwritten when you next launch.
  • They use a shared IP for everything running on the service.
    This one is important - if someone is running a user bot on their service and gets banned, everyone on that IP will be banned. Including you.

Please avoid using repl.it to host your bot. It's not worth the trouble.

boreal ravine
slate swan
#

Also , they Didn't updated their Python version for a long time , it's still 3.8

slate swan
boreal ravine
#

oh

#

I don't use any DB's

slate swan
#

how do I login into my discord bot?

#

using my token in discord bot client website? the website isnt loading idk why

boreal ravine
slate swan
boreal ravine
slate swan
#

Why is it required tho?

boreal ravine
#

!rule 5

unkempt canyonBOT
#

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

slate swan
#

an api wrapper like discord.py would do all the things it can do

slate swan
gloomy quest
slate swan
slate swan
#

*client.guilds

#

so I atleast can show the other discord server mods that "look my bot is int server with 5k members" so they can take my bot in

gloomy quest
boreal ravine
#
    • This means your bot will lag a lot as it gets bigger.
      I doubt any big bots use replit
slate swan
slate swan
#

It's a privacy breach

boreal ravine
final iron
slate swan
#

you can do self hosting and stuff

#

or open a hosting service by yourself

#

raspberry Pi , or there are many reliable services who provide web servers

final iron
#

You can just buy a raspberry pi if you're planning on hosting a medium sized bot

gloomy quest
slate swan
#

yeh

slate swan
#

repl is more of a ide then hosting service

slate swan
#

None of them are meant for bot hosting , so nah for both of them

#

yeah heroku is mostly use for web hosting and stuffs

gloomy quest
#

o h

slate swan
#

If you want free hosting you can try something like trial of google cloud or AWS

#

aws is paid right?

#

they give some trial period

gloomy quest
#

how do people run code in Visual Studio then?

slate swan
slate swan
slate swan
final iron
gloomy quest
#

o k

slate swan
#

and also install packages and path

slate swan
#

and BOOM you are doing a self-hosting for free

slate swan
#

I self-hosted a bot for a week on my pc

#

with some downtimes ofc

#

how do I add space after the command like

@bot.command()
async def help <words>(ctx):
 await ctx.send('commands')

so the thing is suppose i have 2 help commands of different category
1 help show image commands and 2nd video help commands so how do I make the help command use space
!help videos or !help image

#

when I put space after help and type something it shows syntax error

#

is there a way to make my discord bot look like its on phone

gloomy quest
slate swan
gloomy quest
steep estuary
#

how to ignore @ everyone and @ here in user.mentioned_in(message) ?

#

i have afk commands

#

which also reply user when mentioned @ here or @ everyone

#

:/

slate swan
#

!d discord.ext.commands.Bot.group

unkempt canyonBOT
#

@group(*args, **kwargs)```
A shortcut decorator that invokes [`group()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.group "discord.ext.commands.group") and adds it to the internal command list via [`add_command()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin.add_command "discord.ext.commands.GroupMixin.add_command").
slate swan
#

Use a command group

steep estuary
slate swan
steep estuary
#

okk

#

and me :(

slate swan
leaden anvil
slate swan
#

!d discord.Message.mentions

unkempt canyonBOT
#

A list of Member that were mentioned. If the message is in a private message then the list will be of User instead. For messages that are not of type MessageType.default, this array can be used to aid in system messages. For more information, see system_content.

Warning

The order of the mentions list is not in any particular order so you should not rely on it. This is a Discord limitation, not one with the library.

steep estuary
#

it also worksbut the prblm is it react in @ everyone and @ here also

slate swan
#

I don't think you can change it , user.mentioned_in does not check if a particular user obiect is mentioned
It can be roles and everyone/here roles as well

steep estuary
#

can i check if message.content have everyone or here?

steep estuary
#

if the ping is a reply?

steep estuary
#

but i don't want everyone and here

#

i have a option to use <@!userid>

#

but if i will use it it will not react in replies :/

leaden anvil
hasty iron
#

iirc its html metadata

leaden anvil
dim cedar
#

how to edit a role name ?

#

with a cmd

boreal ravine
dim cedar
#

ar bit more

boreal ravine
#

also anyone else having problems creating folders on the webclient

boreal ravine
dim cedar
boreal ravine
#

u only need context or ctx lol

dim cedar
#

=Edit_role HI BYE

dim cedar
boreal ravine
dim cedar
boreal ravine
#

maybe learn more python

dim cedar
boreal ravine
#

functions helped me learn more about arguments

dim cedar
#

working on it

#

but i wanna quick solve now

#

it s urgent

boreal ravine
# dim cedar working on it

!e

def function(role, new_name):
  print(f"Role: {role}\nRenamed To: {new_name}")

print(function("Member", "Cool Kid"))
unkempt canyonBOT
#

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

001 | Role: Member
002 | Renamed To: Cool Kid
003 | None
boreal ravine
#

like that

boreal ravine
leaden anvil
fair axle
boreal ravine
boreal ravine
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**.
fair axle
fair axle
boreal ravine
#

its the same lol

#

nothing changes about discord.Member.send in discord.py and dislash

fair axle
#

is there anyway to send a dm only using dislash not discord

boreal ravine
fair axle
#

k thanks bye

boreal ravine
#

just support for slash commands and stuff lol

#

No problem helping you solve your question

#

πŸ‘

slate swan
#

just use pycord

hasty iron
#

no

tawny lodge
#

hi, is it possible to trigger a link in an embed to perform a function instead of it being an url link?

cloud dawn
tawny lodge
#

no edit the embed

cloud dawn
#

change the content = edit, so i guess were on the same page.

tawny lodge
#

like...i do a search of my sql database...it returns 20 matches in an embed..i'dlike to be able to click on the one i want and have it trigger a function

#

like having it a url link...but not a link, have it trigger foo function instead

cloud dawn
#

Why not just use a paginator. You can do your idea but you'd always need to open the webpage.

tawny lodge
#

example...enbed has 3 choices(links)..clicking on one would send 'you clicked this one' to chat

#

no buttons, emoji reactions, but clicking the actual content in the embed

cloud dawn
#

Like i said you can do that but then a webpage would always open, not to mention the amount of effort it would take to create such a thing.

#

I can't see a method without overengineering the crap out of an embed.

vocal plover
#

because youre missing access for what youre trying to do

slate swan
#

Hey how can I make like if someone votes my bot then the bot will dm them automatically whenever they vote

slate swan
cloud dawn
trail breach
#

discord.Status

#

doesnt work for me

#

??

trail breach
#
@bot.command()
async def challenge(ctx, member: Member):
    if str(member.status).lower() == discord.Status.online:
        return
    if str(member.status).lower() == discord.Status.dnd:
        await ctx.send("Hmm, it appears they don't wish to be disturbed.")
    if str(member.status).lower() == discord.Status.idle:
        await ctx.send("Hmm, The person you have challenged is idle")
    if str(member.status).lower() == discord.Status.offline:
        await ctx.send("Hmm, it appears they'r offline.")
vocal plover
#

do you have presence intents enabled?

trail breach
#

no matter the status it will send Hmm, it appears they'r offline.

slate swan
trail breach
slate swan
#

anyone know how to implement buttons? I looked in the docs and I dont think they have it there yet

#
https://discord.com/api/v9/channels/{gcID}/call/ring

why does a post request to this not work

vocal plover
#

bots cant interact with groupchats

slate swan
#

oh wait

#

yeh i realised

slate swan
vocal plover
#

yes

trail breach
unkempt canyonBOT
#

class discord.ui.Button(*, style=<ButtonStyle.secondary: 2>, label=None, disabled=False, custom_id=None, url=None, emoji=None, row=None)```
Represents a UI button.

New in version 2.0.
slate swan
#

F

trail breach
#

k ty

reef shell
slate swan
reef shell
#

You need to subclass ui.View

#

!d discord.ui.View

unkempt canyonBOT
#

class discord.ui.View(*, timeout=180.0)```
Represents a UI view.

This object must be inherited to create a UI within Discord.

New in version 2.0.
reef shell
#

some examples can be found in the master branch's examples folder

slate swan
#

ah alr ty

#

Would it be okay if I move all my bot events to a separate file, and then later make my code run that file? I have too many events and just wanted to tidy my main bot file up

hardy yoke
#

in cogs you just use @commands.Cog.listener() instead of @bot.event/@client.event

fringe void
#

I wanna make a music bot, I currently use youtube-dl, is there a better alternative?

lament mesa
#

!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)
hollow trail
gaunt herald
#

How can i add currency system to my bot

odd pendant
#

you should do some research into databases

gaunt herald
#

How

odd pendant
#

Well research different types of databases and find one that you like best, i'd recommend postgresql

#

then look at how it's implemented in python and then a basic economy system just consists of storing currency data about individual users

gaunt herald
#

Ok

#

Thanks

lyric moat
#

why it gives an error

  File "main.py", line 111
    @nsfw.error(ctx, error):
    ^
IndentationError: unexpected indent````
#
@cleint.command()
@commands.is_nsfw()
async def nsfw(ctx):
  embed = discord.Embed(title="test", description="test")
async with aiohttp.ClientSession() as cs:
  async with cs.get('https://www.reddit.com/r/nsfw/new.json?sort=hot') as r:
    res = await r.json()
embed.set_image(url=res['data']['children'] [random.randint(0, 25)]['data']['url'])
await ctx.send(embed=embed)

  @nsfw.error(ctx, error):
  if isinstance(error, NSFWChannelRequired):
  await ctx.send(f"Hey! {ctx.author.mention}, sorry but i can't submit nsfw content without nsfw category.")````
slate swan
#

@cleint.command()

odd pendant
#

because your error handler is inside of your command, and you have wong indentation for async with aiohttp.ClientSession() as cs:

fringe void
#

A good example for a free vps?

odd pendant
odd pendant
slate swan
#

Bro, thanks LOL

odd pendant
slate swan
#

Worked like a charm

odd pendant
#

sweet πŸ‘

fringe void
odd pendant
#

solid being anything that's actually viable for discord bots

slate swan
odd pendant
#

pahaha, does it give you any suggestions?

odd pendant
#

i'm not sure, that's just pycharm being pycharm. it's probably a super simple fix

lyric moat
#

no error but command would not respond

@client.command()
async def nsfw(ctx):
  embed = discord.Embed(title="test", description="test")
  async with aiohttp.ClientSession() as cs:
    async with cs.get('https://www.reddit.com/r/nsfw/new.json?sort=hot') as r:
      res = await r.json()
    embed.set_image(url=res['data']['children'] [random.randint(0, 25)]['data']['url'])
    await ctx.send(embed=embed)```
slate swan
#

And I need it for my server

odd pendant
#

does the code still work though? it's only a warning

slate swan
#

Well the only command in it works, but the @command.Cog.listener() doesn't, which is all the code to make the buttons work etc

slate swan
#

So people can use it to open/close a ticket

slate swan
#

And I can't like put it in my main file because that would block out the rest of my bot

slate swan
#

if your bot needs it and it blocks your bots execution, theres no other way than finding a workaround or just using another library for it, the easiest thing to do is to just delete the feature if its necessarily required for your bot but is blocking the execution of your bot without any fix

#

I haven't found a workaround yet, but maybe you have an idea

#

i have never worked with componentsbot

#

Neither have I, this is my first time too

#

so perhaps there should be someone to assist you otehr than me

slate swan
#

or making a help channel

digital slate
#

hello
how to create dashboard for my bot.
With login and communication from web to bot

quasi pawn
#

what do these errors mean

odd pendant
digital slate
#

auth??

odd pendant
#

well you'll need to use auth to let users login

digital slate
odd pendant
#

you'll need to research then

digital slate
#

what should i search

odd pendant
#

what web framework do you want to use?

#

if flask, then google flask discord auth

digital slate
#

ok thanks

solar pike
#
from discord.ext import commands, tasks
from itertools import cycle
status = cycle(['status 1', 'playing under construction'])
class Example(commands.Cog):

  def __init__(self, client):
    self.client = client 

  @commands.Cog.listener()
  async def on_ready(self):
    chnage_status.start()
    print('Bot is online.')

  @tasks.loop(seconds=10)
  async def change_status():
      await client.change_presense(activity=discord.Game(next(status)))
  
  @commands.command()
  async def ping(self, ctx):
    await ctx.send(f'Pong! {round(self.client.latency * 1000)}ms')


def setup(client):
  client.add_cog(Example(client))```
odd pendant
#

quite self explanatory

#

chnage_status isn't defined

solar pike
#

OPS

#

srry

#

ty

boreal ravine
shrewd oxide
#

can someone explain to me why this code does not work?
(The bot does not detect that I pressed the button)

 @commands.command()
    async def button(self, ctx):
        await ctx.send("Buttons!", components=[Button(label="Button", custom_id="button1")])
        interaction = await self.bot.wait_for(
            "button_click", check=lambda inter: inter.custom_id == "button1"
        )
        await interaction.send(content="Button Clicked")
solar pike
stark bobcat
#
@commands.command()
    async def ban(self,ctx, member: discord.Member, *, reason=None):
        if reason == None:
            embed = discord.Embed(
                description=f"You have been banned in {ctx.guild} reason:None", color=0xFF0000)
            await member.send(embed=embed)
            await member.ban(reason=reason)
        else:
            embed = discord.Embed(
                description=f"You have been banned in reason:{reason}", color=0xFF0000)
            await member.send(embed=embed)
            await member.ban(reason=reason)

        embed = discord.Embed(
            description=f"Successfully banned {member}", color=0x3FFF00)
        await ctx.send(embed=embed)```
#

why doesn't this work?

boreal ravine
stark bobcat
boreal ravine
#

oh

#

its in a cog makes sense

solar pike
#

yessir

dapper rain
#

so uhm how to make a music bot? using replit

solar pike
odd pendant
dapper rain
#

wtf

stark bobcat
#

i did tho

boreal ravine
dapper rain
#

i can code some parts

boreal ravine
stark bobcat
#

wym

boreal ravine
#

What do I mean?

#

I'm saying that ur error has nothing to do with that command I guess

odd pendant
#

the problem isnt in your ban command

stark bobcat
#

oh

odd pendant
#

you have Context somewhere and it's not defined

stark bobcat
#

oh

#

wait

boreal ravine
#

Do CTRL + F and search Context

stark bobcat
#

my friend added a file πŸ’€ mb sryy

arctic python
#

@dapper rain We don't allow links through URL shorteners.

boreal ravine
bitter depot
#

!warn 827793666172780604 Please don't advertise your bot here. We aren't an adboard, as per our #rules and #code-of-conduct.

unkempt canyonBOT
#

:x: The user doesn't appear to be on the server.

spice atlas
#
@client.event
async def on_message(message):
    if message.author == client.user.mention:
        return
    if message.content.startswith('$inspire'):
        quote = get_quote()
        await message.channel.send(quote)
    if any(word in message.content for word in sad_word):
        await message.channel.send(random.choice(encouragements))
client.run('')

in this code i want to add mention atribute so that it mentions the user typing the command

odd pendant
#

if you want to mention the member, just use message.author.mention

leaden anvil
#

how to display the body of a website in discord embeds ? like youtube links ?: https://www.youtube.com/watch?v=dQw4w9WgXcQ

The official video for β€œNever Gonna Give You Up” by Rick Astley

β€œNever Gonna Give You Up” was a global smash on its release in July 1987, topping the charts in 25 countries including Rick’s native UK and the US Billboard Hot 100. It also won the Brit Award for Best single in 1988. Stock Aitken and Waterman wrote and produced the track which w...

β–Ά Play video
haughty sedge
#
    ctx = client.get_user(663398794204938255)
    await ctx.send("mini test")```
nonetype has no attr send
fading harness
#

hi

odd pendant
haughty sedge
#

should i fetch

#

the user is me xd, same mutual server

spice atlas
# odd pendant if you want to mention the member, just use `message.author.mention`
@client.event
async def on_message(message):
    if message.author == client.user.mention:
        return
    if message.author.mention.content.startswith('$inspire'):
        quote = get_quote()
        await message.channel.send(quote)
    if any(word in message.content for word in sad_word):
        await message.channel.send(random.choice(encouragements))
client.run('')

showing an error

      if message.author.mention.content.startswith('$inspire'):
AttributeError: 'str' object has no attribute 'content'
haughty sedge
#

me id is 663398794204938255

odd pendant
#

fetch is an api call so you shouldn't do it much really

#

what are you using it for

haughty sedge
#

um

#

in @client.event on_ready

#

whenever bot goes online it messages me (i host bot on repl.it so it reboots every 9 hour or so)

#

temporarily hosting there, ill buy a hosting service once discord verifies my bot (verf unlocked tho)

#

its a weird error i rarely get

upbeat otter
#

guys why does this not show anything?

client = commands.Bot(command_prefix="!", help_command=None, intents=discord.Intents.all(), activity=discord.Activity(type=discord.ActivityType.watching, name='English Podcasts'))

@client.command(name="mean", aliases=["def"])
async def mean(ctx, *, word):
  async with ctx.typing():
    try:
      url = requests.get(f"https://api.dictionaryapi.dev/api/v2/entries/en/{word}")
      try:
        content = url.json()[0]
        embed = discord.Embed(title=word, color=ctx.message.author.color)
      except:
        await ctx.send("Word Not Found")
        return 
      try:    
        info = content["meanings"][0]["definitions"][0]["definition"]
      except:
        info = "Not Defined"
      try:
        synonym = content["meanings"][0]["definitions"][0]["synonyms"][0]
      except:
        synonym = "No Synonym"
      try:
        antonym = content["meanings"][0]["definitions"][0]["antonyms"][0]
      except:
        antonym = "No Antonym"
    except Exception as e:
      print(e)
    embed.add_field(name="Meaning", value=info)
    embed.add_field(name="Synonym", value=synonym)
    embed.add_field(name="Antonym", value=antonym)
    await ctx.message.send(content=None, embed=embed)
#

no errors and no message

haughty sedge
#

it will be await ctx.send or await ctx.reply if u wanna reply

upbeat otter
#

nothing happens

haughty sedge
#

oh hmm

#

tried without content=None

upbeat otter
#

it isnt giving me CommandNotFound error

odd pendant
upbeat otter
haughty sedge
#

alright ty

upbeat otter
#

anyone can help πŸ₯²

soft belfry
#

how can I check if the message has a text?

upbeat otter
soft belfry
#

if message.content != None or message.content == "":

#

this doesnt do the trick

upbeat otter
slate swan
soft belfry
#

attachment only messages

upbeat otter
soft belfry
#

wait

upbeat otter
#

this will check if the message doesnt has text

soft belfry
#

no wait

#

checking for actual text

odd pendant
#

attachments and message content aren't the same

upbeat otter
#

@soft belfry

#

change the operator

#

dont

#

xD

slate swan
#

πŸ’€

upbeat otter
#

it was fine

soft belfry
#

works when if len(message.content)!=0:

upbeat otter
soft belfry
#

thank you

upbeat otter
soft belfry
#

ah one more thing

odd pendant
soft belfry
#

why tho if the shorter works

odd pendant
#

you said you want to check if a message has no text?

upbeat otter
#

it should be ==

#

not !=

odd pendant
#

you can have messages with attachments and no message content

soft belfry
upbeat otter
#

idk

odd pendant
#

checking just for attachments doesn't check for text lol but okay

upbeat otter
#

i need help too πŸ₯²

#
client = commands.Bot(command_prefix=".", help_command=None, intents=discord.Intents.all(), activity=discord.Activity(type=discord.ActivityType.watching, name='English Podcasts'))

@client.command(name="mean", aliases=["def"])
async def mean(ctx, word):
  
    try:
      url = requests.get(f"https://api.dictionaryapi.dev/api/v2/entries/en/{word}")
      try:
        content = url.json()[0]
        embed = discord.Embed(title=word, color=ctx.message.author.color)
      except:
        await ctx.send("Word Not Found")
      try:    
        info = content["meanings"][0]["definitions"][0]["definition"]
      except:
        info = "Not Defined"
      try:
        synonym = content["meanings"][0]["definitions"][0]["synonyms"][0]
      except:
        synonym = "No Synonym"
      try:
        antonym = content["meanings"][0]["definitions"][0]["antonyms"][0]
      except:
        antonym = "No Antonym"
    
      embed.add_field(name="Meaning", value=info)
      embed.add_field(name="Synonym", value=synonym)
      embed.add_field(name="Antonym", value=antonym)
      await ctx.send(embed=embed)
    except Exception as e:
      print(e)  
#

no error and no response

soft belfry
#

but can I send all the attachments at once using webhooks?

odd pendant
upbeat otter
#

now i changed it to bot code

odd pendant
#

yes but requests is still blocking, use aiohttp

upbeat otter
odd pendant
#

look at aiohttp.ClientSession

slate swan
upbeat otter
slate swan
#
except Exception as e:
  print(e)
upbeat otter
#

so?

#

its the same

stiff nexus
#
logger = logging.getLogger('discord')
logger.setLevel(logging.DEBUG)
handler = logging.FileHandler(filename='discord.log', encoding='utf-8', mode='w')
handler.setFormatter(logging.Formatter('%(asctime)s - %(levelname)s - %(name)s - %(message)s'))
logger.addHandler(handler)
``` how do i send this in a webhook?
upbeat otter
#

I am confused how to use aiohttp

#

πŸ₯²

odd pendant
#

have you even researched it lmao

#

the first google result shows a perfect example

upbeat otter
#

ofc

#

what.....

slate swan
upbeat otter
#

okee thank you XD

haughty sedge
#

hey can anyone tell me abt discord rate limit for messages per minute

upbeat otter
#

ah well...it worked when I removed the try and exception statemnets lol

haughty sedge
#

minute?

#

in same channel

upbeat otter
#

otherwise ask someone who knows exactly

haughty sedge
#

hmm k

upbeat otter
#

Me dumb

odd pendant
upbeat otter
lyric moat
#

no error but command would not respond

@client.command()
async def nsfw(ctx):
  embed = discord.Embed(title="test", description="test")
  async with aiohttp.ClientSession() as cs:
    async with cs.get('https://www.reddit.com/r/nsfw/new.json?sort=hot') as r:
      res = await r.json()
    embed.set_image(url=res['data']['children'] [random.randint(0, 25)]['data']['url'])
    await ctx.send(embed=embed)```
celest pelican
#

can somone explain me why my discord bot can't join a voice channel?

odd pendant
cloud dawn
celest pelican
#

?

cloud dawn
#

pass_context has been deprecated for like 4 years.

celest pelican
#

mate I tried 5 differents things and nothing is working

oak warren
celest pelican
#

still not working

oak warren
#

what dpy version ?

celest pelican
#

3.9.7

oak warren
#

huh ?

slate swan
oak warren
#

^^

celest pelican
oak warren
#

await ctx.author.voice.channel.connect() works for me

#

i asked dpy version

#

print(discord.__version__)

celest pelican
#

it is 1.7.3

oak warren
#

its even in the docs

cloud dawn
celest pelican
#

nothing it just doesn't join

cloud dawn
oak warren
celest pelican
#

but I know that the code is right and I've setted the permissions for the bot also right

unkempt canyonBOT
#

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

oak warren
#

that is dpy

#

official

cloud dawn
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)
oak warren
#

ok i was just talking about the join and leave part

#

which is there in that

#

i didnt tell them to use it

cloud dawn
#

like a year or 5

oak warren
#

i think its unlimited time

stiff nexus
#
logger = logging.getLogger('discord')
logger.setLevel(logging.DEBUG)
handler = logging.FileHandler(filename='discord.log', encoding='utf-8', mode='w')
handler.setFormatter(logging.Formatter('%(asctime)s - %(levelname)s - %(name)s - %(message)s'))
logger.addHandler(handler)
``` how do i send this in a webhook?
lament mesa
#

open the file and read it

final iron
#

It wont work most of the time

grim oar
#

z = 10
y = 15
input('which is bigger z or y guess?')
if input = ('z'):
print('wrong')
else:
print ('correct')

#

im trying to get the bot to play a guessing game i have much more of the script but this is where the focused problem is

odd pendant
#

not discord.py related but you need to assign the input to a variable so user_input = int(input('which is bigger z or y guess?'))

#

then if user_input == z:

grim oar
odd pendant
#

you need to indent it properly

final iron
forest blade
#

input will block the script, you are going to want wait_for

queen dagger
#

hi, so i have a while loop, gathering information from an API. and once its running no one else can run commands or myself. any fixes?

odd pendant
#

could you show us the code

#

because requests is blocking, look at aiohttp.ClientSession for your requests

queen dagger
#

ok

sage locust
#

Soz I got a loop that reads reaction to a post that I am using to store statistics. This works great; however, I want to capture replies to my bot's posts and use them as feedback. I can't seem to locate any documentation on how to achieve that.

#

I do seem message.channel.last_message.reference.message_id but this would mean I have to read the entire channel history and pick out the matching reference IDs... Hoping there is a better way.

sick birch
slate swan
#

someone help me pls

crisp hull
#

Try this

crisp hull
#

Give me a sec

slate swan
#

okay

crisp hull
#

Burh

#

@slate swan You don't even have ctx there

#

So just do:

await channel.send (f'Welcome to the Server ' {member.mention} ' to ' {member.guild.name} ' Have fun!')
#

This should work

runic jackal
#

if I have a link as an example, how do you do it that the last 10 characters are automatically removed?

crisp hull
#

What do you mean by that @runic jackal?

crisp hull
#

So you want to remove the "?size=1024"

crisp hull
# slate swan

Can you hover over it with your mouse and show what it says?

runic jackal
sage locust
#

Huh, maybe

crisp hull
#

@runic jackal You have to give me your context. Does the bot has to do that?

sage locust
crisp hull
#

Like the user sends a link and the bot just removes the last 10 letters?

runic jackal
crisp hull
# slate swan wdym

nvm
Just try this:

await channel.send (f'Welcome to the Server {member.mention} to {member.guild.name} Have fun!')
crisp hull
runic jackal
crisp hull
#

passt schon

#

Wieso machst du's nicht einfach mit embeds? Dann brauchst du den Link garnicht und das Bild wird sofort angezeigt @runic jackal

#

Schau, wie hier

runic jackal
#

weil ich den link noch fΓΌr eine api verwenden mΓΆchte, und die api akzeptiert nur links ohne die letzten 10 zeichen

#

also ohne das "?size=1024"

crisp hull
#

ich verstehe

#

Wird der Link in eine Variable gespeichert?

runic jackal
#

ja

crisp hull
#

Dann kΓΆnntest du folgendes versuchen:

av_link = https://blablabla

print(av_link[:-10])```
#

Das wÀre jetzt zum printen. Ich weiß jz nicht genau was du damit vor hast

#

Allerdings bin ich mir ehrlich gesagt nicht ganz sicher ob das nur mit Strings geht. Und auch nicht, ob links als Strings gelten...
Im Prinzip denke ich schon. Das mΓΌsstest du dann testen. Wenn's nicht geht musst du den Link in einen String umwandeln und dann die 10 Characters wie oben gezeigt lΓΆschen

#

@runic jackal

crisp hull
crisp hull
#

Kein Ding^^ Mache ich gerne

hasty iron
#

!rule 4

unkempt canyonBOT
#

4. Use English to the best of your ability. Be polite if someone speaks English imperfectly.

crisp hull
slate swan
#

Event loop is closed

#

im need help

#
from discord.ext import commands
 
from discord_slash import SlashCommand
from discord_slash.utils.manage_commands import create_option
 
import config

client = commands.Bot(command_prefix = '.', intents = discord.Intents.all())
slash = SlashCommand(client, sync_commands = True)
 
 
@slash.slash(name = 'hi', description = 'ΠΏΠΎΠΏΡ€ΠΈΠ²Π΅Ρ‚ΡΡ‚Π²ΠΎΠ²Π°Ρ‚ΡŒ', options = [{"name": "member", "description": "ΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»ΡŒ", "type": 6, "requied": False}], guild_ids = [680754330022051890])
@client.command(aliase = ['hi'])
 
async def hi(ctx, member: discord.Member = None):
    await ctx.send(f"ΠŸΠ΅Ρ€Π΅Π΄Π°ΡŽ ΠΏΡ€ΠΈΠ²Π΅Ρ‚, {member}!")

client.run(config.TOKEN)```
tawdry perch
#

Full traceback?

slate swan
#
  File "C:\Users\marva\python\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\Users\marva\python\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Users\marva\python\lib\asyncio\base_events.py", line 746, in call_soon
    self._check_closed()
  File "C:\Users\marva\python\lib\asyncio\base_events.py", line 510, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x0000015731E3D040>
Traceback (most recent call last):
  File "C:\Users\marva\python\lib\asyncio\proactor_events.py", line 116, in __del__
  File "C:\Users\marva\python\lib\asyncio\proactor_events.py", line 108, in close
  File "C:\Users\marva\python\lib\asyncio\base_events.py", line 746, in call_soon
  File "C:\Users\marva\python\lib\asyncio\base_events.py", line 510, in _check_closed
RuntimeError: Event loop is closed```
tawdry perch
#

So the code does not work?

slate swan
#

yes

hasty iron
#

that’s the full traceback?

#

im sure its not

slate swan
tawdry perch
#

Well I can not help then

slate swan
#
Traceback (most recent call last):
  File "C:\Users\marva\Desktop\python bot\main.py", line 19, in <module>
    client.run(config.TOKEN)
  File "C:\Users\marva\python\lib\site-packages\discord\client.py", line 723, in run
    return future.result()
  File "C:\Users\marva\python\lib\site-packages\discord\client.py", line 702, in runner
    await self.start(*args, **kwargs)
  File "C:\Users\marva\python\lib\site-packages\discord\client.py", line 666, in start
    await self.connect(reconnect=reconnect)
  File "C:\Users\marva\python\lib\site-packages\discord\client.py", line 601, in connect
    raise PrivilegedIntentsRequired(exc.shard_id) from None
discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead.
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x0000015731E3D040>
Traceback (most recent call last):
  File "C:\Users\marva\python\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\Users\marva\python\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Users\marva\python\lib\asyncio\base_events.py", line 746, in call_soon
    self._check_closed()
  File "C:\Users\marva\python\lib\asyncio\base_events.py", line 510, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x0000015731E3D040>
Traceback (most recent call last):
  File "C:\Users\marva\python\lib\asyncio\proactor_events.py", line 116, in __del__
  File "C:\Users\marva\python\lib\asyncio\proactor_events.py", line 108, in close
  File "C:\Users\marva\python\lib\asyncio\base_events.py", line 746, in call_soon
  File "C:\Users\marva\python\lib\asyncio\base_events.py", line 510, in _check_closed
RuntimeError: Event loop is closed```
hasty iron
#

oh how about you read the error you got

tawdry perch
#

Intents?

slate swan
#

I read

hasty iron
#

it tells you exactly what to do

tawdry perch
#

You did not read the message?

slate swan
#

a

#

oh

#

sorry

tawdry perch
#

Np, glad you found it

slate swan
steel trench
#

Rip

slate swan
#

is there a way i can add a pause to a command output? without freezing the entire bot? what id like to do is make something like py await ctx.send(f'message 1') time.sleep(5) await ctx.send(f'message 2') but without freezing the whole bot, just delaying the second output. i can provide more detail if needed

hasty iron
#

!d asyncio.sleep

unkempt canyonBOT
#

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

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

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

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

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

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

thanks

cloud folio
#

How can i add reaction?

#

It says Unknown emoji

#

i tried :white_check_mark.: too (without the dot)

reef shell
#

You need to use this format <:emoji_name:emoji_id>

#

and <a:emoji_name:emoji_id> if the emoji is animated

cloud folio
#

and where can i find emoji id?

reef shell
#

also you can get the emoji and use its string

#

copy the emoji link and there should be an id in the url iirc

cloud folio
#

ok

#

thanks

reef shell
#

wait

#

There is a much simpler way

#

just use \ before the emoji and send it

#

It'll give you the format i told you

cloud folio
#

like /white_check_mark?

#

or wdym?

reef shell
#

no i meant for getting the id

slate swan
#

Was seeing what you guys thought the best method for this would be. I'm trying to check posts in a certain channel for a list of emojis on a post..

For example. I have people add πŸ‡¨ πŸ‡Ί πŸ‡² to posts sometimes. I want to check if those letter are there and if they are delete them

reef shell
#

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

The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.

In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
reef shell
# unkempt canyon

Use this to get what reaction is someone adding and do further execution according to it

slate swan
#

so it's not just one reaction but multiple

#

if they just add πŸ‡¨ for example then do nothing

cloud folio
reef shell
shut gorge
#

Can I have events within commands? Or is that bad practice?

reef shell
#

Bad practice

#

Why would you need that tho

cloud folio
#

the id is always different

shut gorge
#

I want my bot to accept input from the user

#

Maybe I just do not understand

#

Thanks tho

cloud folio
#

i did :white_check_mark.:

#

with \ before it

reef shell
#

You need to use bot.wait_for

shut gorge
reef shell
#

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

The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.

In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
shut gorge
#

Thank you

reef shell
#

"\U00002705"

cloud folio
#

where did you find that?

reef shell
#

I use R.Danny to find that

#

It's a bot

cloud folio
#

i see

#

mmm, interesting

#

thanks

main quarry
#

You can also use unicompact

#

And going to character details

slate swan
#

im testing my error handler, this is what i currently have.

#role
@bot.command('role')
@commands.has_permissions(administrator=True) #permissions
async def role(ctx, user : discord.Member, role : discord.Role):

  if role.position > ctx.author.top_role.position:
    embed = discord.Embed(title=f'Error', description=f'![atick](https://cdn.discordapp.com/emojis/893529433116389416.webp?size=128 "atick") This role is above your highest role!', color=0x2f3136)
    return await ctx.send(embed=embed) 

  if role in user.roles:
      await user.remove_roles(role)
      await ctx.send(f"Removed `{role}` from {user.mention}")

  else:
      await user.add_roles(role)
      await ctx.send(f"Added `{role}` to {user.mention}") 

@role.error
async def role_error(error, ctx):
    if isinstance(error, commands.MissingRequiredArgument):
        embed = discord.Embed(title=f'Error', description=f'![atick](https://cdn.discordapp.com/emojis/893529433116389416.webp?size=128 "atick") ^role  [Member]  [Role]')
        await ctx.reply(embed=embed)
    if isinstance(error, MissingPermissions):
        embed = discord.Embed(title=f'Error', description=f'![atick](https://cdn.discordapp.com/emojis/893529433116389416.webp?size=128 "atick") I do not have permission to manage this role', color=0x2f3136)
        await ctx.reply(embed=embed)```
#

but when i test it, i get no output

#

for any of the errors (missing args and missing perms)

#

how can i get the creator of a channel in audit logs

#

!d discord.AuditLogAction