#discord-bots

1 messages · Page 498 of 1

dense swallow
#

well the bot might send cmds 2 times

trail breach
#

wait so i have no control over those 500 hrs?>

dense swallow
#

idk bcz i dont use it

trail breach
#

anyone else?

dense swallow
#

im currently trying out dan bot

trail breach
#

ohk

dense swallow
#

u have to join their server to make and account btw!

#

also to create a server

trail breach
#

yes ik

dense swallow
#

u have the link? or i can send in dm

trail breach
#

i found on google

dense swallow
#

ok

trail breach
#

is this danbot 24/7

#

if not can i control the time slot

dense swallow
#

might be

trail breach
#

u dont know

dense swallow
trail breach
#

oh nice

trail breach
dense swallow
#

yeah

trail breach
#

k cool

slate swan
#

Hello I was testing my bot since morning and suddenly I was termporary blocked by discord for rate limit
When can I try again?

#

Is it possible to see a duration after which I can run my bot again?

solemn grove
#

from prsaw import RandomStuff

rs = RandomStuff(async_mode = True)

@bot.event
async def on_message(message):
  if bot.user == message.author:
    return
  if message.channel.id == 888436619328233472:
    response = await rs.get_ai_response(message.content)
    await message.reply(response)
  await bot.process_commands(message)

Why I’m getting error?

trail breach
solemn grove
heavy radish
#
Ignoring exception in command rules:
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "/home/runner/My-BOT/cogs/rules.py", line 24, in rules
    await ctx.send(embed=embed)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/abc.py", line 1065, in send
    data = await state.http.send_message(channel.id, content, tts=tts, embed=embed,
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py", line 254, in request
    raise HTTPException(r, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In embed.fields.8.name: This field is required

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

Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1342, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In embed.fields.8.name: This field is required
``` Why am I getting this error?
heavy radish
#

code

#

I cant send it

tough wagon
heavy radish
tough wagon
#

Can't say anything more

dim cedar
#

hello?

tough wagon
#

Because you didn't send code

dim cedar
#

i need help?

heavy radish
#

Its to big

little ether
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.

tough wagon
dim cedar
#

how to make a say command?

#

that can send messages to other channels

tough wagon
dim cedar
tough wagon
tough wagon
#

like async def send(ctx, channel: discord.TextChannel, *, text)

tough wagon
dim cedar
#

my code send messeges to the same channel

#

not in the mentioned one

tough wagon
dim cedar
tough wagon
#

lol

#

you are doing ctx.send

#

do channel.send

dim cedar
#

ok

#

thanks

boreal ravine
#

@tough wagon y spoonfeed

jade jolt
#

he didn't?

heavy radish
#

Figured it out

#

How do I send a picture through an Embed??

dim cedar
#

hey?

slate swan
dim cedar
#

can anyone give me a fully working temp mute source code?

heavy radish
#

Thank You

slate swan
#

that is spoon feeding so no

#

but tempmute is ez

#

just make a time converter and then convert the time to the correct one then mute the member and sleep for the exact amount of time

unkempt canyonBOT
#

Hey @dim cedar!

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

slate swan
#

then unmute

dim cedar
slate swan
#

send to my dms

heavy radish
#

Its currently below everything. I want it before the fields

slate swan
#

then go with thumbnails i suppose

heavy radish
#

hm

slate swan
#

other then that no other way

heavy radish
#

Thumbnails are on the side tho?

visual island
#

yes

#

and there's no way to set it above

slate swan
#

you could get them above all of it

#

just beg discord to add that feature lol

trail breach
#

Monitor timeout??

#

in uptime robot

#

what deos it do??

lament mesa
#

this channel is for stuff related to discords api

trail breach
slate swan
#

Is there a way to have a command handler so I can have separate python files with the commands in? Almost like a sub-cog but i don't have to define each one

valid galleon
#

so im making a server info command, and ive got a few fields right now, and i'll add more later. i decided to test the command, but i get this error:
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'tuple' object is not callable
My Code:

    @commands.command(aliases = ["si", "guildinfo", "gi"])
    async def serverinfo(self, ctx):
        embed = discord.Embed(title = "Server Information",
                              colour = discord.Colour.gold(),
                              timestamp = ctx.message.created_at)

        
        fields = [("ID", ctx.guild.id, True),
                  ("Owner", ctx.guild.owner, True),
                  ("Region", ctx.guild.region, True),
                  ("Created at", ctx.guild.created_at.strftime("%d/%m/%Y %H:%M:%S"), True),
                  ("Members", len(ctx.guild.members), True,)
                  ("Humans", len(list(filter(lambda m: not m.bot, ctx.guild.members))), True),
                  ("Bots", len(list(filter(lambda m: m.bot, ctx.guild.members))), True),
                  ("Banned Members", len(await ctx.guild.bans()), True),
                  ]

        for name, value, inline in fields:
            embed.add_field(name = name, value = value, inline =  inline)  

        await ctx.send(embed = embed)
#

the formatting is a little weird cuz of discord

slate swan
valid niche
#

this is what you did

valid niche
#

!e

t = (1,2,3,4)
t()
unkempt canyonBOT
#

@valid niche :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 2, in <module>
003 | TypeError: 'tuple' object is not callable
valid niche
#

that's literally what you did according to the error

boreal ravine
valid galleon
boreal ravine
#

Easier isn't the best solution

#

try what I said it'll work lel

slate swan
#
@client.event
async def on_guild_channel_join(ctx):
#

Would it works?

#

so i mean the trigger

visual island
#

so 2 times iterating

visual island
visual island
valid galleon
#

alright i'll try that

visual island
#

actually, your code is right

valid galleon
#

alright so i tried converting it into an f string, but that still didnt work

visual island
#

which line is the error again?

valid galleon
visual island
#

its a warning?

#

oh

#

you missed a comma after True)

#

True), is the correct one

valid galleon
#

bruh

#

how tf did i not see that

visual island
valid galleon
#

it works now

#

tysm

visual island
slate swan
#

Can anyone send me pull list of commands in discord.py

#

or how to make embed

valid perch
#

!d discord

unkempt canyonBOT
#

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

Creating a Bot account is a pretty straightforward process.

flat nest
#
ctx.voice_client.stop()
AttributeError: 'NoneType' object has no attribute 'stop'

How is this fixable?

slate swan
#

I mean , the error says it all , bot is not in a voice channel

flat nest
#

the thing is that it is

slate swan
#

how is it possible for .voice_client to return None then

flat nest
#

I found the error

#

i fixed it

slate swan
#

guys, should i run a dpy task every 1 second, if no, what should i use since i have to run the thing exactly every 1 second

slate swan
visual island
#

if the bot joined the voice before it's current session, it will return None also

slate swan
#

im uh

slate swan
#

im running a loop to -= 1 a variable in a json file of every users data (which is a dict)

#

And your memory limits

slate swan
#

i know this is a bad idea but i dont have any other ideas

#

of how to decrease 1

#

in 1 sec

#

what causes you to decrement a variable for every user data? a timer?

slate swan
#

store the user's cooldown time instead of decrementing numbers every second

#

how would i decrease it?

slate swan
# slate swan how would i decrease it?

if this is for a command for example, you can just check during when the user calls a command, and then check if that cooldown time has passed, if it does, allow it

slate swan
#

that's basically how the normal CooldownMapping work

#

good idea

#

but they dont save on restart

#

thats why im doing this

#

what's stopping you from just storing that time data lol

#

since i wont have to store anything if they save

#

saving is storing, what do you even mean

hollow mortar
#

hey i have problem in this code

slate swan
#

but they dont save directly in the bots folder

hollow mortar
#
@bot.event
async def on_raw_reaction_add(payload, ctx):
    if payload.member.id != bot.user.id and str(payload.emoji) == u"📥":
        msg_id, channel_id, category_id = bot.ticket_configs[payload.guild_id]

        if payload.message_id == msg_id:
            guild = bot.get_guild(payload.guild_id)
            role = guild.get_role(891031599708266629) #replace role_id with your role's id
            for category in guild.categories:
                if category.id == category_id:
                    break

            channel = guild.get_channel(channel_id)
            channel_name = ("ticket-{payload.member.display_name}")
            if channel_name in ctx.guild.channels:
                print("you have already a ticket open close it first ")
            else:
                

                ticket_channel = await category.create_text_channel(f"ticket-{payload.member.display_name}", topic=f"A ticket for {payload.member.display_name}.", permission_synced=True)
            
                await ticket_channel.set_permissions(payload.member, read_messages=True, read_message_history=True, send_messages=True)
                await ticket_channel.set_permissions(role, read_messages=False, send_messages=False)

                message = await channel.fetch_message(msg_id)
                await message.remove_reaction(payload.emoji, payload.member)

                await ticket_channel.send(f"{payload.member.mention} Thank you for creating a ticket! Use **'-close'** to close your ticket.")

            try:
                await bot.wait_for("message", check=lambda m: m.channel == ticket_channel and m.author == payload.member and m.content == "-close", timeout=3600)

            except asyncio.TimeoutError:
                await ticket_channel.delete()

            else:
                await ticket_channel.delete()
#
    await coro(*args, **kwargs)
TypeError: on_raw_reaction_add() missing 1 required positional argument: 'ctx'```
#

any help

slate swan
#

but you're saving into a json file every second

boreal ravine
#

also I'm pretty sure that isn't the full error

slate swan
#

hence the error

#

ok tank for idea

#

im gonna rework

hollow mortar
#

now i got this erro

hollow mortar
# boreal ravine `ctx, payload`?
Traceback (most recent call last):
  File "C:\Users\Mohamed_Zeton\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
TypeError: on_raw_reaction_add() missing 1 required positional argument: 'payload'``` when i tried this one
boreal ravine
flat nest
#
source = await discord.FFmpegOpusAudio.from_probe(url2, **ffmpeg_options)

discord.errors.ClientException: ffmpeg was not found.

In what sense?

hasty iron
#

in the sense that you dont have it

flat nest
#

right

vague grove
#

hi, so I'm starting to use slash commands and ran into a pretty big bump in the road, how can I avoid specifying guilds by their id, can i make it universal for all guilds instead of specifying?
code below:

@slash.slash(
    name= "hello",
    description= "Just sends a message",

    guild_ids = [3453423546354235], # problem
    options = [ #ignore this
   ]
flat nest
hasty iron
#

install it

flat nest
#

Requirement already satisfied: ffmpeg in c:\

visual island
#

not pip install

hasty iron
#

not via pip

#

you need the exe

visual island
#

but install it to your computer

hollow mortar
#

you mean the ctx ?

boreal ravine
#

yes

slate swan
#

yes on_raw_reaction_add event only takes the payload argument

hollow mortar
#

then this one wont work

#
if channel_name in ctx.guild.channels:```
#

this line wont work if i remove the ctx

slate swan
#
if channel_name in payload.guild.channels:
#

try that

hasty iron
#

i think its payload.guild_id

slate swan
#

i mean you had guild declared there

hollow mortar
#
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

PS C:\Users\Mohamed_Zeton\Desktop\JOB 1> & C:/Users/Mohamed_Zeton/AppData/Local/Microsoft/WindowsApps/python3.9.exe "c:/Users/Mohamed_Zeton/Desktop/JOB 1/job.py"
CursedMC is ready.
Ignoring exception in on_raw_reaction_add
Traceback (most recent call last):
  File "C:\Users\Mohamed_Zeton\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "c:\Users\Mohamed_Zeton\Desktop\JOB 1\job.py", line 40, in on_raw_reaction_add
    if channel_name in payload.guild.channels:
AttributeError: 'RawReactionActionEvent' object has no attribute 'guild'```
#

didnt work

slate swan
hollow mortar
#

it checks if the name of the channel in the channels list in the server or no

vague grove
hollow mortar
#

what ?

vague grove
hollow mortar
slate swan
hollow mortar
brazen seal
#

how i can do for example help command and if player add emoji message bot edit

slate swan
#

well noemal ppl would get a paginator lib
but some ppl like to code their own paginator

unkempt canyonBOT
#

Hey @tiny ibex!

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

stark bobcat
#
await ctx.guild.category_exists.delete()```
will this work?
tiny ibex
#

Why is it not working?

#

Please help me

boreal ravine
tiny ibex
#

No output

boreal ravine
#

hm

tiny ibex
junior verge
#

Hey, so I got a problem with my discord bot. When I do my .join command the bot joins then instantly leaves and joins back in like .1 seconds that will just hear the join and leave sound

#
@bot.command(pass_context=True, aliases=['j', 'joi'])
async def join(ctx):
    channel = ctx.message.author.voice.channel
    voice = get(bot.voice_clients, guild=ctx.guild)

    if voice and voice.is_connected():
        await voice.move_to(channel)
    else:
        voice = await channel.connect()

    await voice.disconnect()

    if voice and voice.is_connected():
        await voice.move_to(channel)
    else:
        voice = await channel.connect()
        print(f"The bot has connected to {channel}\n")

    await ctx.send(f"Joined {channel}")
hasty iron
#

ctx.guild.voice_client exists

junior verge
#

Yeah I fixed it already

#

I saw it

hasty iron
#

and if you read your code you'll know what happens

junior verge
#

thanks anyways

junior verge
hasty iron
#

thats a probably a youtube_dl error

#

!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)
stark bobcat
#

cause this does not work
```py
elif category_exists == True and channel_exists == False:
print("Category exists but channel does not")
await ctx.guild.category_exists.delete()
x = await ctx.guild.create_category('Mailer')
y = await ctx.guild.create_text_channel('mailer-logs',category=x)
embed = discord.Embed(title="Setup",description=f"Bot has been setted up!, use -accessrole[roles]to give staff access to the channel.Check out more information and configurations with -help.",color=0x1793FC)
await ctx.send(embed=embed)

    elif category_exists == False and channel_exists == True:```
hasty iron
#

Guild object has no attribute category_exists

stark bobcat
#

oh

solemn grove
#

How to delete the message sent by bot after an interval?

slate swan
#

Use delete_after kwarg

boreal ravine
#

Is it possible to edit images

slate swan
#

Yes, with a library like Pillow

boreal ravine
#

Not like that

#

Meaning you send the image and then edit it

tough wagon
boreal ravine
#

U cant right?

slate swan
#

Simply edit the message I guess

#

With the newly updated image

boreal ravine
#

is it confirmed

dim cedar
#

can anyone see what is wrong with my temp mute code?

slate swan
#

Not if you don't share code 😉

dim cedar
# slate swan Not if you don't share code 😉

`time_dict = {"s": 1, "m": 60, "h": 3600, "d": 86400}

invalid_duration_msg = ( "❌ Invalid duration! Here are some examples:\n\n"+ '1tempmute @Big Wumpus 2d Spam- 2 days, with reason "Spam"\n'+ "1 tmute Wumpus 1h- 1 hour without any reason\n"+ "1tempmute Wumpus 20m- 20 minutes without any reason\n"+ "\nYou can also use s for seconds.")
async def time2seconds(send, time):
try:
return int(time[:-1]) * time_dict[time[-1]]
except:
await send(invalid_duration_msg)
return False

@bot.command(aliases=["tmute"])
@commands.guild_only() # So that user can't run the command in DM
@commands.has_permissions(manage_messages=True)
@commands.bot_has_permissions(manage_roles=True)
async def tempmute(ctx , duration: str, *, reason=None,):
unit_tuple = tuple([unit for unit in time_dict.keys()])
sleep_duration = await time2seconds(ctx.send, duration.lower())
if sleep_duration is False:
return

    # If duration does not end with one of the units or is not a number, send an error
    if not duration.lower().endswith(unit_tuple) or not duration[0].isdigit():
        await ctx.send(invalid_duration_msg)
        return

    muted_role = discord.utils.get(ctx.guild.roles, name="Muted")

    await member.add_roles(muted_role, reason=reason)

    embed = discord.Embed(
        title="✅ Member muted",
        color=0xFF6600,
        description=f"{member.mention} was temporarily muted by {ctx.author.mention}",
    )
    embed.add_field(name="Reason", value=reason)
    if not duration[-1].isalpha():
        embed.add_field(name="Auto-unmute after", value=str(duration) + " seconds")
    else:
        embed.add_field(name="Auto-unmute after", value=duration)

    await ctx.send(embed=embed)

    await asyncio.sleep(sleep_duration)
    await member.remove_roles(muted_role, reason=reason)`
slate swan
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

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

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

slate swan
#

Please use this

dim cedar
slate swan
#

No you didn't

#

You pasted here

hasty iron
#

why is time2seconds async

dim cedar
#

i copy pasted it from somewhere

slate swan
#

How to make embed?

boreal ravine
#

nice

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
#

!embed

#

!discord embed

dim cedar
#

but do i have to save it there?

tough wagon
#

@slate swan maybe not here? and !d discord.Embed

tough wagon
#

and send the link

tough wagon
#

thanks

slate swan
#

!d. discord.embed

dim cedar
tough wagon
unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

tough wagon
slate swan
#

!d discord.Embed

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.
tough wagon
#

@slate swan STOP

boreal ravine
#

@dim cedar Whats the error

dim cedar
#

always having this

slate swan
tough wagon
boreal ravine
tough wagon
#

there is #bot-commands

slate swan
#

Not doing

tough wagon
# dim cedar

maybe because you did two spaces before '20s'?

dim cedar
boreal ravine
dim cedar
dim cedar
#

still

#

invalid

#

well it would be great if someone give me a working temp mute code

tough wagon
#

@dim cedar first learn python, because you could print or send your duration
second, - your problem is that you are getting @Riad Admin as duration

#

here (ctx , duration: str, *, reason=None,): you defining duration and reason

#

no member

dim cedar
#

but was lazy to check the code on my own

tough wagon
dim cedar
#

too many lines u know

tough wagon
#

you can do on_guild_join event and check if guild has less member count than you need

#

yes

boreal ravine
#
if guild.member_count > 500:
  await guild.leave()
#

!d discord.Guild.leave

unkempt canyonBOT
#

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

Leaves the guild.

Note

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

hm

tough wagon
#

@boreal ravine he already understood...

boreal ravine
#

Guild is the class name

#

use guild tho

tough wagon
#

how you define in on_guild_join

dim cedar
#

btw

tough wagon
#

you can do like async def on_guild_join(some_guild_haha) and if some_guild_haha

dim cedar
#

there is another thing

tough wagon
dim cedar
#

how can i check multiple ids?

hasty iron
tough wagon
hasty iron
#

if Guild is always True

dim cedar
#

i mean only 2 people can use the command

dim cedar
hasty iron
#

check if ctx.author.id in list_of_ids

tough wagon
hasty iron
#

thats not remotely the same or even similar

dim cedar
#

a def?

hasty iron
#

a list of ids

dim cedar
hasty iron
#

?

dim cedar
#

how make that?

#

a list of ids

tough wagon
hasty iron
#

if you dont know how to make a list you should learn more python

#

!resources

unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

tough wagon
#

list = [123, 1325123]

hasty iron
#

ok then you should be able to do it

dim cedar
#

i mean is it a variable?

tough wagon
hasty iron
#

!e ```py
list = [1, 2, 3]
if 1 in list:
print('1 is in the list')

unkempt canyonBOT
#

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

1 is in the list
dim cedar
#

oh

spring flax
#

nvm

dim cedar
#

i thought you were making a def

hasty iron
#

??

dim cedar
#

my bad

#

lol

tough wagon
#

making a function for ids is weird

dim cedar
#

making simple things complecated

dim cedar
#

but workd for only one id

hasty iron
#

you were confused on how to make a list of ids

dim cedar
hasty iron
#

what

#

read the variable name

dim cedar
#

yep

hasty iron
#

i named like that on purpose

dim cedar
#

hmm

hasty iron
#

so you would know that it is a list of ids

dim cedar
#

i understand now

dim cedar
hasty iron
#

and even if it was a function it wouldnt work

dim cedar
#

it is just i made a is_owner func once

#

that i used to check only one id

#

so i got confused

sweet merlin
#

how do i send files? like images, files, and video?

tough wagon
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**.
tough wagon
#

if guild.member_count > 70:

#

maybe it should be < 70?

sweet merlin
hoary gust
#

@knotty lagoon

hasty iron
#

if the bot leaves then it wont be able to send the message

#

you have to send -> leave, not leave -> send

#

oh

tough wagon
#

!d discord.Guild.system_channel

unkempt canyonBOT
#

property system_channel: Optional[discord.channel.TextChannel]```
Returns the guild’s channel used for system messages.

If no channel is set, then this returns `None`.
tough wagon
#

but won't work in other guilds

#

ok

solemn grove
#

How to add plain text to embeds?

tough wagon
solemn grove
#

Nope outside embed

tough wagon
spring flax
#

if it is not in the embed, it's not part of it, so put seperately

reef shell
hasty iron
#

why

reef shell
#

Cuz, if he don't know about this and use it like send(embed =embed, 'text')

#

I'm not sure tho if it will cause any errorthinkmon

hasty iron
#

if you do it like that it will

reef shell
sweet merlin
#

i put a path to the video

#

await ctx.send(file="C:\\Users\\ASUS\\Desktop\\Doblox\\bljrcoding.mp4")

visual island
#

file=discord.File("your_path")

sweet merlin
#

oh

dim cedar
#
async def clear(ctx, amount=5):
  if ctx.message.author.id in list:    
    await ctx.channel.purge(limit=amount) 
  else:
    @commands.has_permissions(administrator)  
    await ctx.channel.purge(limit=amount)```
#

what is the prob here?

reef shell
#

You need to use the decorator above the function

#

Not inside it

dim cedar
#

thn can u tell me

#

how can me without and the person with admin perm only use this command

reef shell
#

Can you be clear? I didn’t get it

#

Only you and a person with admin perms?

dim cedar
#

hmm

#

but here i dont have admin perm

boreal ravine
#

also just use ctx.author.id

dim cedar
dim cedar
solemn grove
#
@bot.command()
async def embed(ctx):
    def check(message):
        return message.author == ctx.author and message.channel == ctx.channel

    await ctx.send('Waiting for a title')
    title = await bot.wait_for('message', timeout=30.0, check=check)
    await ctx.send('Waiting for a description')

    desc = await bot.wait_for('message', timeout=30.0, check=check)

    embed = discord.Embed(title=title.content, description=desc.content, color=0x72d345)
    await ctx.channel.purge(limit=5)
    await ctx.send(embed=embed)

Got this code from stack overflow

How to send an timeout message?

kindred epoch
#

Use try except

#

except asyncio.TimeoutError

misty stream
#

any1 here knows how to fix this ?

async def updateLoop():
    print(f"\n", end='')
    print(f"\nStarting update loop...", end='')

    await bot.wait_until_ready()
    channel = bot.get_channel(STREAMER_CHANNEL)

    while(True):
        today = datetime.datetime.today()
        weekday = today.weekday()
        now = datetime.datetime.now()
        value = MATRIX[TIMES.index(f"{now.hour}:00")+1][weekday+1]
        if (value != "" and value != None):
            await channel.purge()
            sleep(1)
            await channel.send(f"{value} is now live!\nhttps://www.twitch.tv/{value}")
            MATRIX[TIMES.index(f"{now.hour}:00")+1][weekday+1] = ""
            writeToFile()
            await updateImage()
            updatestreamerweb()
            channel = bot.get_channel(878637135337492502)
            await channel.send('@everyone Make sure to check out our awesome website and watch our featured streamers on it to earn points so you can unlock the request feature role on discord by buying it with the points you earn https://www.so-network.blackbullstudio.eu')
        else:
            print("randomfeature")
        future = datetime.datetime(today.year, today.month, today.day, today.hour, 0)
        await asyncio.sleep( (future-today).total_seconds() )

this will spam randomfeature
when value is empty
but instead of it spamming randomfeature i want it to execute it only once if the function is called so everytime the function is called it will do it once

abstract salmon
#

yo guys how do I make my bot send pictures, instead of links to images?

misty stream
solemn grove
abstract salmon
misty stream
#

from your local machine

#

your pc Xd

abstract salmon
#

sooo not a online db makes sense

#

wait sooo where do I put the image?

misty stream
#

if you want it to send a web image just change it to
await send("www.your image.png"))

#

that might work or make a embed for it

slate swan
#

does this bot have a local file tag?

#

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

nice

misty stream
boreal ravine
solemn grove
#
@bot.command()
async def embed(ctx):
    def check(message):
        return message.author == ctx.author and message.channel == ctx.channel

    await ctx.send('Waiting for a title')
    title = await bot.wait_for('message', timeout=30.0, check=check)
    await ctx.send('Waiting for a description') 
    try:
  except asyncio.TimeoutError
     await ctx.channel.purge(limit=5)
     await ctx.send('Timeout', delete_after=2)



    desc = await bot.wait_for('message', timeout=30.0, check=check)
   try:
  except asyncio.TimeoutError
     await ctx.channel.purge(limit=5)
     await ctx.send('Timeout', delete_after=4) 


    embed = discord.Embed(title=title.content, description=desc.content, color=0x72d345d)
slate swan
reef shell
#

also you are doing it wrong

#

!d try except

unkempt canyonBOT
#
try

8.4. The try statement

The try statement specifies exception handlers and/or cleanup code for a group of statements...

reef shell
#

!d except

unkempt canyonBOT
#

8.4. The try statement

The try statement specifies exception handlers and/or cleanup code for a group of statements...

dim cedar
#

Hello

#

In this code exactly where would i type

compact ruin
#

Question apart from JSON is there any other way to store data for a discord bot?

wheat bison
#

hey i am struggling with "InteraktionType" it dosnt work.
i know is is removed or something.
my problem is i don't know was InteraktionType is and also don't know what i have to use instead?

dim cedar
#

?

#

Anyone?

boreal ravine
#

.join?

craggy cloak
#

fixed

tough wagon
unkempt canyonBOT
#

@discord.ext.commands.check(predicate)```
A decorator that adds a check to the [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") or its subclasses. These checks could be accessed via [`Command.checks`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command.checks "discord.ext.commands.Command.checks").

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

If an exception should be thrown in the predicate then it should be a subclass of [`CommandError`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandError "discord.ext.commands.CommandError"). Any exception not subclassed from it will be propagated while those subclassed will be sent to [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error").
ionic wadi
#

!codeblock

unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

ionic wadi
#
class WIP(commands.Cog, name='WIP (SOON)'):
    def __init__(self, bot):
        self.bot = bot
        

    @commands.command()
    async def members(self, ctx):
        total = len(ctx.guild.members)
        online = len(list(filter(lambda m: str(m.status) == "online", ctx.guild.members)))
        idle = len(list(filter(lambda m: str(m.status) == "idle", ctx.guild.members)))
        dnd = len(list(filter(lambda m: str(m.status) == "dnd", ctx.guild.members)))
        offline = len(list(filter(lambda m: str(m.status) == "offline", ctx.guild.members)))
        humans = len(list(filter(lambda m: not m.bot, ctx.guild.members)))
        bots = len(list(filter(lambda m: m.bot, ctx.guild.members)))
        await ctx.send(f"Total: {total}\nHumans: {humans}\nBots: {bots}\nOnline: {online}\nIdle: {idle}\nDo not Distrub: {dnd}\nOffline: {offline}")```

Output:
#

Total: 294
Humans: 285
Bots: 9
Online: 1
Idle: 0
Do not Distrub: 0
Offline: 293

warped bronze
#

"'Nonetype' has no attribute 'send'" on line 50

#

Only happened after I added the check for admin

hasty iron
#

ctx.guild.system_channel is None

warped bronze
#

what

#

I should explain

#

It works fine when there is an active system channel and it does exactly what it's supposed to when there is, but when I disabled the system channel it doesnt send the "No system channel" message and gives me an error for a line below it that it shouldnt have even checked (to my knowledge)

#

If Guild.system_channel is None should move it onto the await ctx.send("no system channel part") and then go down to return and end there, but it doesnt

hasty iron
#

Guild.system_channel is not the same as ctx.guild.system_channel

warped bronze
#

Oh

hasty iron
#

do you know the difference between an instance and a class

ionic wadi
warped bronze
#

I asked what I should know about py before trying to make a discord bot and I wasnt really told anything I didnt grasp but that's probably a poor excuse

hasty iron
#

How much Python do I need to know?

discord.py is ultimately a complicated Python library for beginners. There are many concepts in there that can trip a beginner up and could be confusing. The design of the library is to be easy to use -- however the target audience for the library is not complete beginners of Python.

With that being said, beginners tend to use this library quite liberally anyway and while I appreciate the endeavour and tenacity it should be noted that asking for help here does take up the valuable time of volunteers. As a result certain knowledge is required before you can actively participate in the help channels:

  • The difference between instances and class attributes.
  • How to use data structures in the language.
    • dict/tuple/list/str/...
  • How to solve NameError or SyntaxError exceptions.
  • How to read and understand tracebacks.

This list is not exhaustive

warped bronze
#

Oh

#

I will go look some stuff up on yt and figure those things out

tough wagon
#

How can I fix that?

        print(self.bot.user.mention)
        print(message.content)
        print(message.content.startswith(self.bot.user.mention))```
hasty iron
#

check for both

#

with the ! and without

#

startswith can take a tuple of strings

upbeat otter
#

guys, why does the activity not work?

client = commands.Bot(command_prefix=[".", "ec "], help_command=None, intents=discord.Intents.all(), activity=discord.Watching("Demon Slayer"))
tough wagon
hasty iron
#

you already have the string for without

tough wagon
#

yes

hasty iron
#

so make the one with !

tough wagon
#

uh okay, i forgot how do it but i think there is info in net...

hasty iron
#

you dont know how to make a string?

tough wagon
hasty iron
#

what

upbeat otter
hasty iron
#

!e ```py
string = '@dapper matrix'
print(string)

unkempt canyonBOT
#

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

<@​!123>
hasty iron
#

???

tough wagon
#

OHMYGOD

unkempt canyonBOT
#

class discord.Activity(**kwargs)```
Represents an activity in Discord.

This could be an activity such as streaming, playing, listening or watching.

For memory optimisation purposes, some activities are offered in slimmed down versions:

• [`Game`](https://discordpy.readthedocs.io/en/master/api.html#discord.Game "discord.Game")

• [`Streaming`](https://discordpy.readthedocs.io/en/master/api.html#discord.Streaming "discord.Streaming")
shy schooner
# upbeat otter anyone 🥲

you should define a separate variable named

activity = discord.Activity(type=discord.AcitivityType.watching(name='SOmething'))

and then do commands.Bot(...., activity=activity)

shy schooner
upbeat otter
# shy schooner i just edited some stuff

activity = discord.AcitivityType.Watching(name='Demon Slayer')
discord has no attribute 'Activity type'

and u just made another variable and did the same thing 😑

upbeat otter
#

😑 , it still doesnt work

shy schooner
upbeat otter
tough wagon
shy schooner
#
activity = discord.Activity(type=discord.AcitivityType.watching(name='SOmething'))
#

you can change watching to playing or listening

boreal ravine
#

!d discord.ActivityType.watching

unkempt canyonBOT
boreal ravine
#

hm

upbeat otter
slate swan
#

the different var is probably not needed

upbeat otter
#

i tried already

slate swan
#

no way

boreal ravine
shy schooner
tough wagon
shy schooner
upbeat otter
#

umm ok my bad 🥲

#

i made a typo
i forgot the spellings of activity 😑

#

Still its not working 😢

tough wagon
#

hyperlemon error

shy schooner
#

error

boreal ravine
#

error

upbeat otter
#

just a minute

tough wagon
#

Name 'spam' is not defined

upbeat otter
#

@shy schooner @boreal ravine

#

client = commands.Bot(command_prefix=[".", "ec "], help_command=None, intents=discord.Intents.all(), activity=discord.ActivityType.watching(name='Demon Slayer'))

tough wagon
#

YoU NoObS

boreal ravine
#

@upbeat otter try

upbeat otter
tough wagon
#
client = commands.Bot(command_prefix=[".", "ec "], help_command=None, intents=discord.Intents.all(), activity=discord.Activity(type=discord.ActivityType.watching, name='Demon Slayer'))```
#

this

boreal ravine
#

activity = discord activity(discord actitiy listening(name="i"))

hasty iron
upbeat otter
upbeat otter
upbeat otter
warped bronze
#

I got the systemCheck command to work and now I understand a bit of class vs instance, thank you blanket

upbeat otter
boreal ravine
#

do u have intents

upbeat otter
tough wagon
upbeat otter
boreal ravine
upbeat otter
tough wagon
#

🤯

upbeat otter
upbeat otter
boreal ravine
upbeat otter
#

wrong reply 🥲

hasty iron
# slate swan wat

that was the error their previously not-edited code would have raised

upbeat otter
boreal ravine
#

o nvm

tough wagon
#

#read the fucking manual

upbeat otter
tough wagon
#

me2

upbeat otter
#

brotha

bitter depot
tough wagon
#

xD

hasty iron
#

rtfm

boreal ravine
#

Means no ^

tough wagon
#

i thought i didn't say anything toxic, okay..

slate swan
#

let's name Bot bot

#

bruhkitty

hasty iron
#

what

slate swan
#

client = commands.Bot

reef shell
#

Wdym

ionic wadi
#

It just doesnt output the right data

slate swan
#

!e

myString = 102
myInt = "Hello World!"
print(myString, myInt)
unkempt canyonBOT
#

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

102 Hello World!
quaint beacon
#

!e

unkempt canyonBOT
#
Command Help

!eval [code]
Can also use: e

*Run Python code and get the results.

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

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

quaint beacon
#

!e [print("Hi!")]

unkempt canyonBOT
#

@quaint beacon :white_check_mark: Your eval job has completed with return code 0.

Hi!
hasty iron
#

#bot-commands

quaint beacon
#

!e
myString = 102
myInt = "Hello World!"
print(myString, myInt)

#

i

#

ok

maiden fable
#

Imagine trying to make an eval command since hours

slate swan
#

trying to make?

maiden fable
#

Yea

#

My eval command sucks :stare:

slate swan
#

how did you do it

#

make a different file

#

write it, run it, get the output?

maiden fable
#

Eh, I want the bot, ctx and other vars

pliant gulch
#

!d exec

unkempt canyonBOT
#

exec(object[, globals[, locals]])```
This function supports dynamic execution of Python code. *object* must be either a string or a code object. If it is a string, the string is parsed as a suite of Python statements which is then executed (unless a syntax error occurs). [1](https://docs.python.org/3.10/library/functions.html#id2) If it is a code object, it is simply executed. In all cases, the code that’s executed is expected to be valid as file input (see the section “File input” in the Reference Manual). Be aware that the [`nonlocal`](https://docs.python.org/3.10/reference/simple_stmts.html#nonlocal), [`yield`](https://docs.python.org/3.10/reference/simple_stmts.html#yield), and [`return`](https://docs.python.org/3.10/reference/simple_stmts.html#return) statements may not be used outside of function definitions even within the context of code passed to the [`exec()`](https://docs.python.org/3.10/library/functions.html#exec "exec") function. The return value is `None`.
maiden fable
slate swan
#

oh nice

#

didn't know that was a thing

maiden fable
#

Haha

slate swan
#

how can you do an auto role on a discord bot

potent jetty
slate swan
#

yes

potent jetty
#

you can use on_member_join for that

slate swan
#

this isnt workin

#

i dont get why

#

can anyone help please?

#

why is there a syntax spelling error thig

potent jetty
#

indentation

slate swan
#

its not opening cos of that

slate swan
#

ok

#

deindent that

#

lol

#

there was no :

#

also indent the role line

#

!resources and check this out because this just hurts

unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

slate swan
slate swan
#

it movef

#

that's just an IDE thing I guess

slate swan
#

restart your IDE

#

fixed it

#

it didnt work

#

do i have to import something for it?

#
@client.event
async def on_member_join(member):
    role = discord.utils.get(member.guild.roles, name='role name here')
    await member.add_roles(role) ```
#

this should be your code now

stark hearth
#
@client.event
 async def on_member_join(member):
 
role = discord.utils.get(member.guild.roles, name='role name here')
 await member.add_roles(member, role) 
slate swan
#

no

#

that has 3 mistakes lol

potent jetty
#

this hurts ngl

stark hearth
#

there has to be member in member.add_roles

slate swan
#

member.add_roles

#

it's a method of the class

#

stop watching old youtube tutorials yert

slate swan
#

do you have intents?

#

show me your error

#

theres no error it just doesnt work

#

what does it do

#

nothing

#

is the bot online?

#

it goes on like normal then nothing happens when i join the server

slate swan
#

can you show me your whole code?

#

like the whole thing without the token

#

delete it rn

#

you gave us your token

#

that's a really poor way to get spammed lol

#

!code use this

unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

slate swan
#

again

#

it has old token

stark hearth
slate swan
#

oh nice

stark hearth
slate swan
#

not new

#

do the commands work?

#

yes

slate swan
unkempt canyonBOT
#

Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.

To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.

Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

intents = Intents.default()
intents.members = True

bot = commands.Bot(command_prefix="!", intents=intents)

For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.

slate swan
#

wait oof

#

still not working

#

rerun the bot? and turn intents on from the dev portal as well

slate swan
stark hearth
slate swan
#

and why import commands twice?

#

srry im a begginer

slate swan
#

and turn them onn

stark hearth
#

@slate swan

#

its on the bot tab

slate swan
stark hearth
#

also did you give your bot an administrator invite like when inviting it to the server?

slate swan
#

YESSS

stark hearth
#

ok just checking

slate swan
#

wait wait wait

#

FINNALLY THX SOO MUCH ALL THE VIDS ARE OUTDATED

#

IT LITRALLY TOOK LIKE 3 HOURS

slate swan
stark hearth
#

lmao

boreal ravine
slate swan
#

everytime gonna me paste this

stark hearth
slate swan
boreal ravine
#

@slate swan too small

slate swan
#

pp?

stark hearth
boreal ravine
#

pp?

slate swan
#

don't mind it

#

what's too small

stark hearth
slate swan
#

everyone's gotta realise this at some point

#

why does this not worko

@bot.command()
async def setcareer(ctx, user:commands.MemberConverter=None, career:str):
    if user is None:
        user = ctx.author
boreal ravine
#

@slate swan whats the error?

stark hearth
ripe talon
#

Hello, can I somehow check an if statement, also if there is no command triggering it?

zenith flicker
#

is there a way to add a subcommand to commands.HelpCommand?

upbeat otter
#

guys, i was following a tutorial, but the client.send_message doesnt work here, what can i replace it with?

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

  if lvl_start < lvl_end:
    await client.send_message(channel, f"{user.mention} has leveled up to {lvl_end}")
    users[str(user.id)]["level"] = lvl_end
cloud dawn
#

Don't use a tutorial that is as old as discord self.

upbeat otter
cloud dawn
#

if channel is defined just channel.send()

upbeat otter
cloud dawn
#

import random

upbeat otter
#

import random at the top of your code first

cloud dawn
#

Also no need to put it inside an f string bare variable is okay.

upbeat otter
#

yessir

tight lark
#

guys this is my code ```py
@commands.command()
async def mafia(self,ctx,member:discord.Member):
if ctx.message.author.guild_permissions.manage_roles or (self.clanleadera in ctx.message.author.roles) and (self.mafiaa in ctx.message.author.roles):
if (self.euphoriaa in member.roles) or (self.weeda in member.roles) or (self.hallucinationa in member.roles) or (self.aliensa in member.roles) or (self.outlawsa in member.roles) or (self.brotherhooda in member.roles) or (self.dystopiaa in member.roles) or (self.valhallaa in member.roles) or (self.legenda in member.roles) or (self.antibullya in member.roles) (self.untildeatha in member.roles) or (self.fivetha in member.roles) or (self.kalopsiaa in member.roles) or (self.fargoa in member.roles) or (self.phenomenalsa in member.roles) or (self.immortalsa in member.roles) or (self.khokhaa in member.roles) or (self.aesira in member.roles) or (self.djpa in member.roles) or (self.clouda in member.roles) or (self.favelaa in member.roles) or (self.nevadaa in member.roles) or (self.chayatina in member.roles) or (self.bdba in member.roles) or (self.tchintchina in member.roles) :
await ctx.send(embed=self.aembed(ctx.message.author,member))
else:
if (self.mafiaa not in member.roles) :
await member.add_roles(self.mafiaa)
await ctx.send(embed=self.sembed(ctx.message.author,member))
else:
if (self.mafiaa in member.roles) :
await member.remove_roles(self.mafiaa)
await ctx.send(embed=self.fembed(ctx.message.author,member))

#

get me this error

#

Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "main.py", line 173, in mafia
if (self.euphoriaa in member.roles) or (self.weeda in member.roles) or (self.hallucinationa in member.roles) or (self.aliensa in member.roles) or (self.outlawsa in member.roles) or (self.brotherhooda in member.roles) or (self.dystopiaa in member.roles) or (self.valhallaa in member.roles) or (self.legenda in member.roles) or (self.antibullya in member.roles) (self.untildeatha in member.roles) or (self.fivetha in member.roles) or (self.kalopsiaa in member.roles) or (self.fargoa in member.roles) or (self.phenomenalsa in member.roles) or (self.immortalsa in member.roles) or (self.khokhaa in member.roles) or (self.aesira in member.roles) or (self.djpa in member.roles) or (self.clouda in member.roles) or (self.favelaa in member.roles) or (self.nevadaa in member.roles) or (self.chayatina in member.roles) or (self.bdba in member.roles) or (self.tchintchina in member.roles) :
TypeError: 'bool' object is not callable

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

hasty iron
#

what the fuck

tight lark
slate swan
tight lark
tight lark
#

Is there any solution

cloud dawn
#

!e True()

unkempt canyonBOT
#

@cloud dawn :x: Your eval job has completed with return code 1.

001 | <string>:1: SyntaxWarning: 'bool' object is not callable; perhaps you missed a comma?
002 | Traceback (most recent call last):
003 |   File "<string>", line 1, in <module>
004 | TypeError: 'bool' object is not callable
cloud dawn
#

That's what's wrong

hasty iron
#

dude there is no way we’re going to look through every condition to find what caused the error

slate swan
forest blade
#

Missing a or

slate swan
#

How does one make a global event handler to provide a message when say I encounter the following message "404 Not Found (error code: 10062): Unknown interaction"?

cloud dawn
cloud dawn
lament mesa
maiden fable
#

at last I have made my eval command, thanks to Bluenix

boreal ravine
#

How do I split bots & members?

lament mesa
#

use the built in filter function

boreal ravine
#

which

#

iz there a doc about it

maiden fable
#

!d filter

unkempt canyonBOT
#

filter(function, iterable)```
Construct an iterator from those elements of *iterable* for which *function* returns true. *iterable* may be either a sequence, a container which supports iteration, or an iterator. If *function* is `None`, the identity function is assumed, that is, all elements of *iterable* that are false are removed.

Note that `filter(function, iterable)` is equivalent to the generator expression `(item for item in iterable if function(item))` if function is not `None` and `(item for item in iterable if item)` if function is `None`.

See [`itertools.filterfalse()`](https://docs.python.org/3.10/library/itertools.html#itertools.filterfalse "itertools.filterfalse") for the complementary function that returns elements of *iterable* for which *function* returns false.
stark hearth
# unkempt canyon
len(list(filter(lambda m: not m.bot, ctx.guild.members))))
len(list(filter(lambda m: m.bot, ctx.guild.members))))

first line is for members
second for bots

maiden fable
#

Yea that

pliant gulch
#

You could also use sum

#

Although it could be slower not sure might be the other way around

slate swan
#

Hey

#

rently my account got diabled and i owned a verified discord bot is there a way to send a message in each server to inform them to invite the new bot?

#

like ?announce (message)
*sends in every server (message)

hasty iron
#

you need the old bots’ servers

slate swan
#

yeah i do

#

i have a txt file of server names id and owner id

upbeat otter
#

Guys, i am using on_message event to store messages in a txt file, is there a way to ignore the other bot's messages?

pliant gulch
#

Sending messages in every server your bot is esp since its verified will get it banned most likely

hasty iron
#

ok use the old bot to broadcast the message

#

iterate through Bot.guilds

#

and get a channel you want

pliant gulch
#

Do you have some sort of support server or some other platform to make an announcement

slate swan
hasty iron
#

well you can probably just edit the old bots’ commands to include an invite to the new bot

slate swan
#

well

#

the bot will get banned 15 days after getting disabled

pliant gulch
#

by default your bot ignores other bots messages already

upbeat otter
pliant gulch
#

if not you will have to do return if the author's bot attribute is true

hasty iron
pliant gulch
upbeat otter
pliant gulch
#

so either way even if it isn't a command it should get ignored

upbeat otter
#

I want to ignore messages by other bots @pliant gulch

hasty iron
#

check Message.author.bot

#

oops

#

!d discord.User.bot

unkempt canyonBOT
upbeat otter
#

ohhh

#

thanx

upbeat otter
hasty iron
#

no

upbeat otter
#

what....

hasty iron
#

message.author returns either a Member or User which both have the bot attribute

upbeat otter
#

oh...

#

so...

#

now what 🥲

#

sorry for the dumb questions 🥲

pliant gulch
#

bot is the attribute you access it via dotnotation

#

it is either True or False

#

you put that in an if statement

#

which determines if you return

upbeat otter
#

ohhh

#

thenx

upbeat otter
#

?

pliant gulch
#

No instance vs class

#

discord.User is the class

upbeat otter
#

oh

pliant gulch
#

you want the instance of the class

upbeat otter
#

yesh

hasty iron
#

message.author returns one

upbeat otter
#

oh

pliant gulch
#

when checking if something is false you shouldn't do == rather use is

pliant gulch
#

== is checking if the value is the same vs is which checks if it is the same thing

lament mesa
#

use is for singletons

high flame
#

i love how kotoba bot contributors are just 8

#

the bot is hard to make tho pithink

hasty iron
#

what is kotoba

high flame
#

a bot for learning jp, mostly used in japanese learning servers

hasty iron
#

why would you learn japanese through a discord bot

high flame
#

it's very easy for learning kanji with it

lament mesa
#

Duolingo lemon_swag

high flame
#

meh bad for jp (we're switching topic..)

hasty iron
#

me who barely even knows katakana

high flame
#

bruh

upbeat otter
#

i still cant find how to ignore other bot's messages 😢

high flame
#

hmm? just an if statement

upbeat otter
hasty iron
#

i mean we told you earlier

upbeat otter
#

i am dumb

hasty iron
#

we explained

high flame
upbeat otter
hasty iron
#

then how did it not work

upbeat otter
#

Idk 🥲, most prolly cz i am dumb and new for discord py

pliant gulch
#

I'm assuming you got stuck on the instance vs class part

pliant gulch
#

Have you any knowledge in OOP?

upbeat otter
craggy cloak
#

If I put a song in que, my bot won't play it. If I let him leave the voice channel and then I let him rejoin it works, but otherwise not? Can someone help me?
My bot won't play 2 songs in a row

pliant gulch
#

Learn more then

upbeat otter
pliant gulch
#

I'm sure if you just googled instance vs class it could help explain it as well

slate swan
#

why is there a error here

lament mesa
#

send the code and the error

weak kite
#

How can I go about getting all the messages from every channel and public/private thread from my private server into a json file. I want to put the data into pandas and analyze it.

weak kite
slate swan
upbeat otter
#

guys, i figured out how to ignore messages in on_message, but when i use @client.command, it still logs the message of the bot

slate swan
weak kite
# slate swan

there needs to be an _ after YDL
you cant have a space in a variable name

#

YDL_OPTIONS

weak kite
slate swan
#

it goes on and then off what i do

slate swan
weak kite
#

yeah alright but I found the problem

slate swan
#

what is it

weak kite
#

line 9 - line 39 is indented within the __init__ method

slate swan
#
@bot.command()
@has_permissions(delete_messages=True)
async def purge(ctx, messages: discord.messages):
      await ctx.channel.purge(limit=1)
      await message.delete
#

how do i make a purge command?

#

why isnt my script working

hollow mortar
#
@bot.event
async def on_raw_reaction_add(payload):
    message_id = payload.message_id
    if message_id ==  891778706899628032: ## add id msg of the msg you want ppl to react to to get role 
        guild_id = payload.guild_id
        guild = discord.utils.find(lambda g: g.id ==guild_id, bot.guilds)
        if payload.emoji.name == 'AU':
            role = discord.utils.get(guild.roles, name='AU')
        elif payload.emoji.name == 'NA':
            role = discord.utils.get(guild.roles, name='NA')
        else:
            role = discord.utils.get(guild.roles, name=payload.emoji.name)
        if role is not None:
            member = discord.utils.find(lambda m : m.id == payload.user_id, guild.member)
            if member is not None:
                await member.add_roles(role)
                print("done")
            else: 
                print("memeber not found")```
#

any one know whats the problem of this code it wont work

#

this error

#
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

PS C:\Users\Mohamed_Zeton\Desktop\JOB 1> & C:/Users/Mohamed_Zeton/AppData/Local/Microsoft/WindowsApps/python3.9.exe "c:/Users/Mohamed_Zeton/Desktop/JOB 1/job.py"
CursedMC is ready.
Ignoring exception in on_raw_reaction_add
Traceback (most recent call last):
  File "C:\Users\Mohamed_Zeton\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "c:\Users\Mohamed_Zeton\Desktop\JOB 1\job.py", line 111, in on_raw_reaction_add
    member = discord.utils.find(lambda m : m.id == payload.user_id, guild.member)
AttributeError: 'Guild' object has no attribute 'member'```
slate swan
#

why isnt this working?

hollow mortar
#

it works like this but give me memeber not found
memeber not found

#

it should work idk why its not working

kindred epoch
final iron
# slate swan

Send the specific code that isn't working and the error

slate swan
#

there is no error

#

it just goes on then off

hollow mortar
#

how to fix it ?

final iron
slate swan
#

no

#

the terminal

final iron
#

Wdym

craggy cloak
#

I create a music bot what should i install to use Spotify links?

unkempt canyonBOT
#

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

craggy cloak
#

Oke

#

Lol

hollow mortar
craggy cloak
final iron
slate swan
final iron
#

Just reminding you of the rules

final iron
#

@slate swan line 9

#

You used client before you defined it

#

Won't fix your issue but it is an issue that can be fixed

slate swan
#

how

final iron
#

How what

final iron
#

Move line 9 down

slate swan
#

like this?

final iron
#

Yes

#

You should either get a help channel or ask in #editors-ides to fix your vsc issue

slate swan
#

im so confused why isnt it working

ripe jackal
#

Hello, can someone help me?
This is the code:
`@client.command()
async def buildembed(ctx):
def check(message):
return message.author == ctx.author and message.channel == ctx.channel

await ctx.send('Waiting for a title')
title = await client.wait_for('message', check=check)

await ctx.send('Waiting for a description')
desc = await client.wait_for('message', check=check)

await ctx.send('Channel ID')
guild = client.get_guild(12345678)
channel = guild.get_channel(await client.wait_for('message', check=check))

embed = discord.Embed(title=title.content, description=desc.content, color=discord.Color.blue())
await channel.send(embed=embed)`

And this is the error: discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'get_channel'

#

What should i do?

final iron
#

Which line?

ripe jackal
#

channel = guild.get_channel(await client.wait_for('message', check=check))

#

the 3rd one from bottom to top

pliant gulch
#

The first error means that client.get_guild returned None meaning not cached, wrong id etc

#

And then channel = guild.get_channel(await client.wait_for('message', check=check)) won't work either

#

Since it returns a message object not the content of it

pliant gulch
#

you would need to access the content attribute of the message then cast int

#

Which then gets passed into get_channel

slate swan
ripe jackal
ripe jackal
pliant gulch
#

yes this would work

#

But firstly you need to fix the get_guild

#

as the error suggests its returning None

#

Either not cached or you gave it the wrong id

ripe jackal
#

how to do it?

pliant gulch
#

Read my above messages

ripe jackal
pliant gulch
#

Either the guild isn't cached in the bots guild cache or you gave it the wrong id

#

Which means when you run get_guild it can't find it thus returns None

final iron
ripe jackal
#

i just wanna make a cool bot :p

final iron
#

To sell?

ripe jackal
#

nope

#

just for me

final iron
#

"Discord Nitro Gen and Checker"

hasty iron
#

you probably don’t have enough python knowledge for a discord bot

ripe jackal
hasty iron
#

it’s better if you learn python before doing it

#

!resources

unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

ripe jackal
hasty iron
#

ok?

ripe jackal
#

dw, i don't sell anything

hasty iron
#

ok

ripe jackal
#

my friend asked me if i can put it in my about-me

#

for his server

#

he sells it

fallow mauve
#

i need help

ripe jackal
#

as you can see i dont have nitro lol

fallow mauve
#

how do i set member cooldowns for commands on my bot?

final iron
fallow mauve
ripe jackal
#

idk, he have nitro and sells nitros

#

anyway, can you pls tell me exactly what i need to do pls

hasty iron
ripe jackal
#

`@client.command()
async def buildembed(ctx):
def check(message):
return message.author == ctx.author and message.channel == ctx.channel

await ctx.send('Waiting for a title')
title = await client.wait_for('message', check=check)

await ctx.send('Waiting for a description')
desc = await client.wait_for('message', check=check)

await ctx.send('Channel ID')
guild = client.get_guild(12345678)
int((await client.wait_for('message', check=check)).content)
channel_id = await client.wait_for('message', check=check)
channel = guild.get_channel(int(channel_id.content))
embed = discord.Embed(title=title.content, description=desc.content, color=discord.Color.blue())
await channel.send(embed=embed)`
hasty iron
ripe jackal
#

?

final iron
#

Not what I was looking for

hasty iron
#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

fallow mauve
#

can someone pls help me?

ripe jackal
final iron
#

Nope

fallow mauve
ripe jackal
#

sorry

#

and you need to import asyncio

ripe jackal
fallow mauve
#

as you can tell im a python master and didnt just start using it yesterday

#

wait, i did