#discord-bots

1 messages · Page 525 of 1

slate swan
#

if len(channel.members) == 0

#

why would you fetch anything

#

What about there are 5 people in the voice channel (the limit should be 6) and someone leaves (the voice limit should be 5)

slate swan
#

bro what

#

Okay let me tell you my goal

#

use the on_voice_state_update event

#

I want to make an unlimited voice limit

slate swan
#

whenever someone joins/leaves, set the limit to len(voice.members) + 1

#

Yep

#

That's easier, But the default limit should be 2

#

except when it's 0, set it to 2

#

How can I do that

#

simple if statement

#
if voice.members == 0:
    limit = 2
#
    limit = 2
else:
    limit = len(voice.members) + 1```
#

LoL

#

Python is easy sometimes

slate swan
flint void
#

How to do this with await message.edit()?

slate swan
#

await message.edit(file=file, embed=embed)

#

same thing

flint void
#

hmm

flint void
velvet relic
#

Discord.py how to make bot wait for 10 reactionthen do stuff ?

#

Need some smart dude hand here

slate swan
flint void
# flint void How to do this with `await message.edit()`?
  file = discord.File(f"{fileName}.png", filename=f"{fileName}.png")
  embed = discord.Embed(title="Preview", color=0x5865f2)
  embed.set_image(url=f"attachment://{fileName}.png")
  await message.edit(content=f"Save code: `{base}:{eye}:{eyebrow}:{mouth}:{extra}`", file=file, embed=embed)

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: Object of type File is not JSON serializable

#

what

slate swan
#
@commands.Cog.listener()
    async def on_voice_state_update(self, member, before, after):
        if not before.channel and after.channel and member.id == member:
            print(f"{member} Joined")
        elif before.channel and not after.channel and member.id == member:
            print(f"{member} Left")

How do I make it so it gets the member id automatically?

#

So I don't set the member.id == 34578923458236452345

flint void
slate swan
flint void
velvet relic
#

Need help

velvet relic
#

Anyone ?

velvet relic
#

Anyone smart enough to help me ?

flint void
slate swan
#

Thanks

velvet relic
#

Please sir

slate swan
stark garnet
#

I am trying to use the on_command_completion event, such that it logs all of the commands that I run.

I have a command game and you can specify, for example random_number after it and it will start up the game. When the command shows up in the log, though, it only shows the game portion of the command, not the random_number portion/game selection part.

Here is my code: https://pastebin.com/RHhzTYrV

And a screenshot of the log message is below.

slate swan
#

This doesn't work...

flint void
flint void
slate swan
#

oops

#

thanks 😂

flint void
#

np

slate swan
#
[WARNING] Failed to overwrite commands in <Guild id=98765> due to 403 Forbidden (error code: 50001): Missing Access```
flint void
slate swan
#
from discord.ext import commands
from dislash import slash_commands
from dislash.interactions import *

client = commands.Bot(command_prefix="!")
slash = slash_commands.SlashClient(client)
test_guilds = [12345, 98765]

@slash.command(
    name="hello", # Defaults to function name
    description="Says hello",
    guild_ids=test_guilds # If not specified, the command is registered globally
    # Global registration takes up to 1 hour
)
async def hello(inter):
    await inter.reply("Hello!")

client.run("token")```
#

im need help

#
import discord
from discord.ext import commands
from discord.ext import tasks
from discord import Intents

import pytz
import datetime
import atexit

import asyncio

import sqlite3
 
import varsfile
#--------------------------------
trusted_users = varsfile.import_trusted()
token = varsfile.tokenload()

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

client = commands.Bot(command_prefix='>', intents=intents)

@client.event()
async def on_ready():
    print('bot online')

@client.event()
async def on_member_join(member):
    saloon = client.get_channel(id=varsfile.newcomers_logs)
    print(member)

client.run(token)```

getting error `TypeError: event() missing 1 required positional argument: 'coro'
PS D:\.personaldata\bots\TheBrotherhood> & "C:/Program Files/Python39/python.exe" d:/.personaldata/bots/TheBrotherhood/main.py
trustedusers.json LOADED
Token.txt LOADED
Traceback (most recent call last):
  File "d:\.personaldata\bots\TheBrotherhood\main.py", line 24, in <module>
    @client.event()
TypeError: event() missing 1 required positional argument: 'coro'`
#

(sorry for the huge block)

flint void
slate swan
#

why the error it doesnt work

#

I tried using client.process_commands

#

all the errors with missing arguments are not working

slate swan
flint void
#

@client.event() to @client.event

slate swan
#

what does it change technically?

#

doe the () make it expect an argument?

steel trench
boreal ravine
slate swan
boreal ravine
#

@slate swan does ur command ur doing need args?

#

maybe ur doing the command with args (!poll 1 2 3) or the command doesnt have args (!poll)

slate swan
boreal ravine
#

hm

steel trench
#

Does the actually command work as it is supposed to

slate swan
#

yes

boreal ravine
#

like only !poll

slate swan
#

no

#

it works like this

#

if i send just >poll it sends no msg

boreal ravine
#

idk then

boreal ravine
slate swan
#

yes

boreal ravine
#

did the error pop up if u did that?

lilac latch
slate swan
slate swan
boreal ravine
steel trench
#

Nothing shows up in the terminal, right?

lilac latch
slate swan
#

and with the other commands when are with missing arguments error the bot is not responding

boreal ravine
lilac latch
slate swan
boreal ravine
lilac latch
#

Anyone who can help me with ffmpeg in discord.py please

slate swan
boreal ravine
#

hm

slate swan
#

with the permissions error it works

#

its responding

#

maybe something here

#

??

boreal ravine
#

@slate swan can u show me ur full command error

slate swan
#
@poll.error
async def poll_error(ctx, error):
  if isinstance(error, commands.MissingRequiredArgument):
    await ctx.send(f"_ArgumentError: Specify me a content to poll❗_", delete_after=3)
lilac latch
#

Bruh you are taking the message as an argument and not entering it in the command?

boreal ravine
#

hm

boreal ravine
slate swan
lilac latch
steel trench
#

Make it so temporarily any error defaults to the missing permissions one

slate swan
#

i think i fixed it

#

uh no

#

Hello my ping is 3985

#

And my bot is not responding

#

it works on 8 ball but not on the other commands

slate swan
#

Is it for my ping?

#

ig yes

#

It was responding good an hour ago

#

Ok thanks

#

problem with your host ig

slate swan
#

I am testing on local

#

oh

#

Pydroid 3

#

idk

#

I code on phone

#

but is not respondingbc of the ping

#

So i use pydroid3

#

Hmm

#

Ok thanks

#

Have a good day

#

you 2

#

I need some quick help, how do i make my unmute role require the person u want to unmute to have the muted role?

#

bc now if he isnt muted, it just says unmuted

#

i want it to say user isnt muted

steel trench
#
if muterole not in member.roles:
    await ctx.send("This user is already unmuted.")
    return
#

@slate swan ^

#

Get info for the role and store it in muterole

boreal ravine
slate swan
#
@bot.command(description="Unmutes a specific user.")
@commands.has_permissions(manage_messages=True)
async def unmute(ctx, member: discord.Member):
   mutedRole = discord.utils.get(ctx.guild.roles, name="Muted")
   if mutedRole not in member.roles:
       embed = discord.Embed(
           title = "Error",
           description = (f"{member} isn't muted!"),
           color = (0xe67e22)
       )
       await ctx.send(embed=embed)
   elif mutedRole in member.roles:
       await member.remove_roles(mutedRole)
       await member.send(f" you have been unmuted in: - {ctx.guild.name}")
       embed = discord.Embed(
           title = "Unmuted", 
           description = f"**Succesfully unmuted {member.mention}!**", 
           color = (0xe67e22)
           
   )
   await ctx.send(embed=embed)
    ``` how do i fix it sending 3 embeds
reef shell
#

use return

steel trench
#

^

#

return after you get the one you want

solemn grove
#

How to send multiple embed in the same message?

brazen raft
#

I think that's impossible.

boreal ravine
#

!d discord.abc.Messageable.send

unkempt canyonBOT
#

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

Sends a message to the destination with the content given.

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

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

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

bruh?

boreal ravine
#

Theres an embeds kwarg

#

u can use that to send multiple embeds I think

grim gulch
#

hi

stone palm
#

how do i use on_timeout?

slate swan
#
    @commands.Cog.listener()
    async def on_voice_state_update(self):
        voice = self.client.get_channel(896396049151832165)
        if len(voice.members) == 0:
            limit = 2
            voice.edit(user_limit=limit)
        else:
            limit2 = len(voice.members) + 1
            voice.edit(user_limit=limit2)

Why this doesn't work?

#

I want this:

If 2 people are in voice = self.client.get_channel(896396049151832165) limit + 1

#

So the limit is 3

wintry shore
royal dock
slate swan
# royal dock are you getting any errors?
d:\Desktop\MaxTheBot\cogs\UnlimtedVoice.py:26: RuntimeWarning: coroutine 'VoiceChannel.edit' was never awaited
  voice.edit(user_limit=limit2)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
d:\Desktop\MaxTheBot\cogs\UnlimtedVoice.py:23: RuntimeWarning: coroutine 'VoiceChannel.edit' was never awaited
  voice.edit(user_limit=limit)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
royal dock
slate swan
#

oh

slate swan
# royal dock you have to await those two voice.edit like `await voice.edit(user_limit=limit)`
Traceback (most recent call last):
  File "C:\Users\samjo\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
TypeError: unlimted.on_voice_state_update() takes 1 positional argument but 4 were given
Ignoring exception in on_voice_state_update
Traceback (most recent call last):
  File "C:\Users\samjo\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
TypeError: unlimted.on_voice_state_update() takes 1 positional argument but 4 were given
Ignoring exception in on_voice_state_update
Traceback (most recent call last):
  File "C:\Users\samjo\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
TypeError: unlimted.on_voice_state_update() takes 1 positional argument but 4 were given
Ignoring exception in on_voice_state_update
Traceback (most recent call last):
  File "C:\Users\samjo\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
TypeError: unlimted.on_voice_state_update() takes 1 positional argument but 4 were given
#

Now this error

pliant gulch
#

on_voice_state_update takes 3 arguments. member, before and after. Here you are only giving it self and not the other args

#

You have to add those

#

!d discord.on_voice_state_update

unkempt canyonBOT
#

discord.on_voice_state_update(member, before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") changes their [`VoiceState`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceState "discord.VoiceState").

The following, but not limited to, examples illustrate when this event is called...
slate swan
royal dock
#

just wanted to link the same as i found it strange having nothing there other than a self haha :P

novel rampart
#

how to i convert this all roles mention

#

i mean i want to get all roles in that server and that all roles did mention also

still tiger
#

Hi, I have a question about discord.py. How do I edit a message with a file instead of text?

novel rampart
#

i do like this ```py
total_roles = [ctx.guild.roles]

novel rampart
#

i want to get only that roles mention

#

did anyone help me

spring flax
pliant gulch
novel rampart
pliant gulch
still tiger
pliant gulch
#

Then inside of Message.edit it has an attachments kwarg, you pass in a list of new attachments

still tiger
#

Ok, thanks for that!

pliant gulch
#

attachment being discord.Attachment

still tiger
#

Thanks

vestal owl
#
    raise ClientConnectorError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host discord.com:443 ssl:default [getaddrinfo failed]```
#

Does anyone know what this means?

vestal owl
#

my bot is not starting up, I regenerated the secret client code

tough wagon
#

ehm

vestal owl
#

hold on

tough wagon
#

just put your token into client.run('')

vestal owl
#

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

vestal owl
tough wagon
#

then idk sry

vestal owl
#

here is the full traceback

#

do you know what it means

tough wagon
#

you did bot.run('YOUR SUPER SECRET CODE THAT YOU SHOULDN'T SHOW DELETE THAT MESSAGE AND REGENRATE IT')

#

but you should put token there

vestal owl
#

Oops

#

its fine, its just a testing bot so nothing can happen

#

I regenerated anyways

tough wagon
#

this is toke @vestal owl

vestal owl
#

woops

tough wagon
#

omfg ubuntu's screenshots are so bright

vestal owl
#

I was using the wrong token lmfao

tough wagon
solid wave
#

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

solid wave
#

Sorry

#

I was just checking it out

tough wagon
#

np
NOTE: there is #bot-commands

solid wave
#

thanks

wild mist
#

can someone help me make my bot welcome people

tough wagon
#

!d discord.on_member_join

unkempt canyonBOT
#

discord.on_member_join(member)``````py

discord.on_member_remove(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") leaves or joins a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").

This requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be enabled.
vestal owl
#
Bot flashcards_test is operational!
Ignoring exception in command changeto:
Traceback (most recent call last):
  File "C:\Users\minua\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "C:\Users\minua\Downloads\ex.py", line 33, in changeto
    ctx = await bot.get_context(message)
  File "C:\Users\minua\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\discord\ext\commands\bot.py", line 847, in get_context
    view = StringView(message.content)
AttributeError: 'Context' object has no attribute 'content'

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

Traceback (most recent call last):
  File "C:\Users\minua\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\discord\ext\commands\bot.py", line 903, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\minua\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\discord\ext\commands\core.py", line 855, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\minua\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\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: AttributeError: 'Context' object has no attribute 'content'```
#

Im sorry, but this is being really strange

tough wagon
vestal owl
#

?

#

hold on, I should await it

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.

vestal owl
#
@bot.command()
async def changeto(message):
    ctx = await bot.get_context(message)
    await ctx.send('Finished')```
tough wagon
#
@bot.command()
async def changeto(ctx):
    await ctx.send('Finished')```
#

why message

#

like... ...

vestal owl
#

oh sorry

#

let me send the full code

#
@bot.command()
async def changeto(message):
    ctx = await bot.get_context(message)
    con = sqlite3.connect('lang_store.db')
    cur = con.cursor()
    auth = str(message.author)
    auth = auth.split('#')
    tb_n = auth[0]
    create_table = f'''CREATE TABLE IF NOT EXISTS
    {tb_n}(id INTEGER PRIMARY KEY AUTOINCREMENT, User TEXT, Language TEXT);'''
    cur.execute(create_table)
    lang = str(message.content)
    user = f'{message.author}'
    cur.execute(f'INSERT INTO {tb_n} VALUES (NULL, ?, ?)', (user, lang))
    con.commit()
    await ctx.send('Finished')```
#

I just find it easier like this

#

and I create the ctx object, but it doesnt work

tough wagon
#

just delete ctx = bot.get_context and change message to ctx

vestal owl
#

Then how do I get message.content

waxen granite
#

get the msg using its id and message.content

tough wagon
#

uh learn pyt.... okay, you should pass arg

tough wagon
vestal owl
#

yeah I could do that

tough wagon
#

but he need arg

waxen granite
#

what is this bro?

#

async def changeto(message):

tough wagon
#

like changeto(ctx, *, lang):

vestal owl
tough wagon
#

and lang will be en or ch or something else

vestal owl
#

but there is also something else I could do

tough wagon
#

what

ornate glade
#

Is it possible to have one event call on multiple other functions?

tough wagon
#

wdymean?

slate swan
#

give more details mate

tough wagon
#

you can call event as a function await event_name in that file

tough wagon
slate swan
#

technically everything is possible if you try hard enough

#

can you send code + intentions?

ornate glade
#

Yes

slate swan
#

aight we'll be right here

ornate glade
vestal owl
#

lol light mode

ornate glade
#

XD

vestal owl
#

absolute menace

tough wagon
#

-eyes

slate swan
#

i see what you wanted to do

#

you should tru asyncing dms

#

its likely not the error in this case but you should consider it

ornate glade
#

Okay

tough wagon
#

no you should try removing dms function and doind await reportuser

slate swan
#

also

slate swan
#

no need to define a function inside a funtion

ornate glade
#

Got ya

slate swan
#

Also in case you do this in order to avoid a mess in your code, dm me i have a good advice

ornate glade
#

Okie

slate swan
#
    @commands.Cog.listener()
    async def on_voice_state_update(self, member, before, after):
        counter = 2
        if len(after.channel.members) == 2 and after.channel.id == 896396049151832165:
            counter += 1
            await after.channel.edit(user_limit=counter)
        elif len(after.channel.members) < counter and after.channel.id == 896396049151832165:
            counter -= 1
            await after.channel.edit(user_limit=counter)
        elif len(before.channel.members) == 0  and before.channel.id == 896396049151832165:
            await before.channel.edit(user_limit=2)
#

Why isn't this working?

#

I want this: If there are 68 members in voice the user limit should be always 1 more than the members

#

!p discord.member_role_add

unkempt canyonBOT
#
Bad argument

Converting to "int" failed for parameter "pep_number".

#
Command Help

!pep <pep_number>
Can also use: get_pep, p

Fetches information about a PEP and sends it to the channel.

slate swan
tough wagon
#

no

slate swan
#

ok

slate swan
slate swan
# tough wagon any errors?
Traceback (most recent call last):
  File "C:\Users\samjo\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "d:\Desktop\MaxTheBot\cogs\UnlimtedVoice.py", line 21, in on_voice_state_update
    if len(after.channel.members) == 2 and after.channel.id == 896396049151832165:
AttributeError: 'NoneType' object has no attribute 'members'
tough wagon
#

okay, let someone more help you i don't want to work with voice states)

slate swan
#

😢

heavy gull
#

How do I make the bot send the name of the permissions that a user has?

tough wagon
#

member.guild_permissions?

slate swan
#

ctx.send(member.guild_permissions)

heavy gull
slate swan
#

I wanna do it for fun

slate swan
#

is that it?

tough wagon
tough wagon
unkempt canyonBOT
#

property guild_permissions: discord.permissions.Permissions```
Returns the member’s guild permissions.

This only takes into consideration the guild permissions and not most of the implied permissions or any of the channel permission overwrites. For 100% accurate permission calculation, please use [`abc.GuildChannel.permissions_for()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.GuildChannel.permissions_for "discord.abc.GuildChannel.permissions_for").

This does take into consideration guild ownership and the administrator implication.
slate swan
#

And if no one is in the voice it should be 2

#

And if someone leaves but there are still people

#

it lowers it

#

The user limit should lower by one

#

i see

slate swan
#

And I named the channel (Unlimted)

#

😄

#

hahahhaa

#

i would use a task instead of an event NGL

#

its slower but better

#

Yeah a task will check it

#

But the event happens instantly

slate swan
#

So do you know how to do it with events

#

it would be a waste of resources to make a 0.5s task i agree with you

slate swan
#

i don't think there even is a way to make such an event

#

I guess my ideas are big

#

I see xD

slate swan
#

it's kinda off topic but i like to see young people learning useful stuff instead of watching tiktoks (if you are a young person that is, i also like to see older people learn such complex things)

tough wagon
#

but im too lazy to explain

slate swan
#

hahha i see

#

Like..., Because I started coding python a month ago, And I never coded before tat, I don't know what to build, I just get these crazy ideas

#

i am good at planning the code but when it comes to actual typing im kinda bad

#

Yeah, I know what to do

#

But don't know how to perform it

slate swan
tough wagon
slate swan
slate swan
#

Let's not get too off topic

tough wagon
slate swan
#

i will do some research

tough wagon
#

then how are you trying to do that?

slate swan
tough wagon
slate swan
tough wagon
#

then do you have other goal?

slate swan
#

I did that so you guys understand better

slate swan
tough wagon
#

explain it

slate swan
#
@commands.Cog.listener()
    async def on_voice_state_update(self, member, before, after):
        counter = 2
        if len(after.channel.members) == 2 and after.channel.id == 896396049151832165:
            counter += 1
            await after.channel.edit(user_limit=counter)
        elif len(after.channel.members) < counter and after.channel.id == 896396049151832165:
            counter -= 1
            await after.channel.edit(user_limit=counter)
        elif len(before.channel.members) == 0  and before.channel.id == 896396049151832165:
            await before.channel.edit(user_limit=2)
tough wagon
#

not a code, explain like:
I want if a channel deletes then bot goes to audit logs, find who deleted it and send a log into log channel

slate swan
#

They want the channel to have the limit of people always +1 to the number actually in it

#

it also raises and lowers accordingly

#

Okay so... The default user_limit should be 2, And if 2 people join the user limit changes to 3 and if 3 people join the user limit changes to 4, And so on and so fourth, And if one of them leave the user limit should be always 1 more than the members in voice

tough wagon
#

duhhh, that's sooo hard to not spoonfeed

#

@slate swan can I do that? ^

slate swan
tough wagon
#

xD

slate swan
#

i only allow it if you explain afterwards

#

🤣

dusk pike
#

Does anyone havea good databasse for a discord bot

slate swan
#

@slate swan are you owner?

slate swan
#

or smth

#

just a random user

#

Why is he asking you tho 😂

dusk pike
#

Thx

#

I want to code one

slate swan
tough wagon
slate swan
dusk pike
#

Lol

#

I have made the bot itself

#

but it has no code

slate swan
#

Ummm?

#

@dusk pike good luck on using SQL mate

dusk pike
#

Lol

#

I will try

slate swan
#

its gonna be so long and hard

dusk pike
#

It is a fun challenge

slate swan
#

shall i send a happy PDF in your DMs?

dusk pike
#

Yes pls

slate swan
#

So am I getting help?

tough wagon
#

yes i am writing an explain @slate swan

slate swan
slate swan
#

chill

#

you're aiming too high even for us

#

(not like I am very good anyways)

#

can you help me please

slate swan
#

send code

#

what

#

send the code

#

🤣 tf happened

misty stream
#

hello

#

im facing a issue

#

with getting images off a website

#

its a 18+ issue/ website Xd

slate swan
unkempt canyonBOT
#

Hey @misty stream!

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

misty stream
#

what how do i share the code

slate swan
#

its likely not an issue from discord py

mortal mango
#

please dont share 18+ urls in the code

slate swan
#

send everything in DM's

misty stream
slate swan
#

help for event on webhook create ;-;

tough wagon
#

@slate swan
first we define to much after.channel, so:
voice = after.channel
second i see that you do it only for channel with specific id, so:
if voice.id != 896396049151832165: return
third the channel can be none cause of it deleted or all member left, then:
if voice is None: return
next you need to check if there is amount of users in channel as it's limit, so:
if len(voice.members) == voice.user_limit:
counter += 1
next if there is less then 2 members in voice then set limit to 2:
elif len(voice.members) < 2:
counter = 2
and last if member left channel then do limit -1:
elif len(voice.members) < voice.user_limit:
counter -= 1
so we have:

    @commands.Cog.listener()
    async def on_voice_state_update(self, member, before, after):
        counter = 2
        voice = after.channel
        if voice is None:
            return
        if voice.id != 896396049151832165:
            return
        if len(voice.members) == voice.user_limit:
            counter += 1
        elif len(voice.members) < 2:
            counter = 2
        elif len(voice.members) < voice.user_limit:
            counter -= 1
        else:
            return
        await voice.edit(user_limit=counter)```
#

finalllly

tough wagon
#

@slate swan i forgot one thing in final code i edited

slate swan
#

@slate swan@tough wagon nice you guys got it sorted out!

#

It's not working...

#

😂

tough wagon
#

omg what error?

slate swan
#

No error

tough wagon
#

oh my f.... god

slate swan
#

you forgot smth

#

elif len(voice.members) > voice.user_limit:

tough wagon
#

i just hate that stupid voices, always problems with them

slate swan
#

It goes up to 3

#

isnt better to add this?

#

And never comes down to 2 again

#

can you get it to 4?

#

and then back to 3?

slate swan
#

or does it lock on 3?

slate swan
tough wagon
slate swan
tough wagon
#

did u change code? @slate swan

slate swan
#
@commands.Cog.listener()
    async def on_voice_state_update(self, member, before, after):
        counter = 2
        voice = after.channel
        if voice is None:
            return
        if voice.id != 896396049151832165:
            return
        if len(voice.members) < 2:
            counter =2
        elif len(voice.members) < voice.user_limit:
            counter += 1
        elif len(voice.members) > voice.user_limit:
            counter -= 1
        else:
            return
        await voice.edit(user_limit=counter)
#

its something i never used before

#

i think i messed up

tough wagon
slate swan
#

lmao yeah

#

i just saw it

final iron
#

How could I create a task that would loop every certain amount of time

tough wagon
maiden fable
unkempt canyonBOT
#

class discord.ext.tasks.Loop```
A background task helper that abstracts the loop and reconnection logic for you.

The main interface to create this is through [`loop()`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.loop "discord.ext.tasks.loop").
slate swan
final iron
maiden fable
slate swan
#

So what do I do?

slate swan
#

🤣 jk

maiden fable
slate swan
maiden fable
#

Hey @slate swan what happened

maiden fable
tough wagon
#

@slate swan sorry, maybe i could help you by joining that server and test your bot but i havent got more time

maiden fable
#

@slate swan what is the issue?

slate swan
#
@tasks.loop(seconds=120)
async def loop():
      pass

loop.start()
slate swan
#

it will iterate every 2 minutes

maiden fable
slate swan
tough wagon
maiden fable
#

Yeaaa

slate swan
tough wagon
#

now i know one more thing more

#

in my life

maiden fable
#

Radium just gave a small example lol

slate swan
#

Give them the documentation link, they will learn more than from your copy pasta

maiden fable
#

I linked them to the docs

slate swan
#

but no

#

examples work very good for simple topics

#

its better to send detailed docs when it comes to complex stuff ofc

tough wagon
#

@slate swan i can help you tomorrow (7:00 AM at mine) if you want (it is 9 PM at mine)

slate swan
#

Don't worry

tough wagon
#

ok

slate swan
#

In <t:1633838400:R>

slate swan
#

gg

tough wagon
#

lol

slate swan
#

Can help you <t:1633838400:F>

tough wagon
slate swan
tough wagon
slate swan
#

if a mod sees all the off topic spamemd here we al good for jail

tough wagon
#

noone cares

slate swan
#

how can I deaf my bot on join a channel?

wise shell
#

I did everything it says to do on this page and got the bot working with the docker-compose up command. It is getting the bot to work on my test server.. It says it's connected. https://www.pythondiscord.com/pages/guides/pydis-guides/contributing/sir-lancebot/

Now I just need to finish this tutorial, which is pretty great. https://vcokltfre.dev/

A tutorial on how to use discord.py to create your own Discord bot in Python, written to fix the flaws of many other popular tutorials.

slate swan
tough wagon
#

ok

wise shell
#

It was worse than I thought, the things I had to do to get set up were pretty complicated. It's not very beginner-friendly.

slate swan
#

Uhhhh

#

And that's why you need to learn before

tough wagon
#

ok

robust remnant
#

can someone help me make it so every role i create will be above a specific role?

slate swan
tough stone
#

Hey everyone. I tried to create a Discord bot that can check lots of messages. Is there a way to use discord.Client function, like message.delete into on_message(self, message), into my thread ? I included the "message" variable into my thread

#

Thanks !

slate swan
#

do you specifically want to delete certain messages?

#

AKA bad words for example?

tough stone
#

When I receive a message, I create a new thread with the message inside. So after, I can check which message it is. For example, in the thread, I check if message.content contains bad words

#

And I want to delete the message if it's true

tough stone
#

Can I do it into my thread ?

slate swan
#

yeah ofc

tough wagon
#

radium will help ig i will just say that you need 2.0v of dpy)

slate swan
#

i forgot that threads became a thing for a splisecond ngl

#

do bots even have access to them?

tough stone
#

Yes, they have admin access

slate swan
#

i will do some research, excuse me for a second

tough stone
#

The bot is working to recognise banned words

#

Into the thread

#

So now I should delete the message

slate swan
#

i see

tough wagon
#

NOTE: on_message works for threads too, your bot just need to be in it

slate swan
#

message.delete() will do it mate

slate swan
tough stone
#

I have this return : RuntimeWarning: coroutine 'Message.delete' was never awaited

tough wagon
#

await message.delete()
NOTE: learn python

slate swan
#

sorry i forgot to specify u have to await

tough stone
slate swan
tough wagon
tough stone
#

So I should rename my thread function "def run" into "async def run" ?

tough wagon
#

yes!

tough stone
#

Let's try so

tough wagon
#

and await it when calling

tough wagon
tough stone
#

So when I'm doing "thread.start()"

tough wagon
#

oh

#

nope

#

thread.start dont need await

tough stone
#
class ThreadMsg(threading.Thread):
    def __init__(self, msg):
        threading.Thread.__init__(self)
        self.msg = msg

    async def run(self):
        # test de la censure
        temp = self.msg.content.lower()
        if any(map(temp.__contains__, censure)):
            print("Bad word detected")
            await self.msg.delete()

It's not working D:

tough wagon
#

where is run.start()?

#

what error?

slate swan
tough stone
#
    async def on_message(self, message):
        m = ThreadMsg(message)
        m.start()
#

I'm a casu thread user

#

It's probably wrong

tough wagon
#

what... is... this...?

#

where... is... run.start()?

slate swan
#

🤣 you should rest mate

#

you're forcing yourself

tough wagon
slate swan
tough stone
#

It's working well like I did

tough wagon
#

im.... still... noob...

tough stone
#

I just need to know if I can use discord functions into a thread, that's all

slate swan
#

i never used threads they still dont exist for me

shy bane
#

hey guys

tough stone
#

I can see that Threads is supported in discord.py 2.0+ as you said

shy bane
#

i need help

tough stone
#

using discord.thread

slate swan
tough wagon
tough stone
#

But it's still in beta

shy bane
#

someone how to do like if i say hello the bot will say hello and edit the message to hi

tough stone
#

I'll try so

shy bane
#

like edit message

tough wagon
slate swan
shy bane
#

i know

unkempt canyonBOT
#

await edit(content=..., embed=..., embeds=..., attachments=..., suppress=..., delete_after=None, allowed_mentions=..., view=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the message.

The content must be able to be transformed into a string via `str(content)`.

Changed in version 1.3: The `suppress` keyword-only parameter was added.
slate swan
#

oh okay

shy bane
#

i mean the bot will do it

slate swan
#

i misread sry

shy bane
#

this is embed

tough wagon
#

yes

slate swan
#

The bot will send hello and then edit it to hi after some time right?

shy bane
#

i mean like if he say hello he will edit him self to hi

slate swan
#

I see

#

did you do the message sending part?

shy bane
#

me?

slate swan
#

yes

shy bane
#

what do you mean

#

sending part

tough wagon
#
    message.edit(content='hi')```?
shy bane
#

like

slate swan
#

will the bot say anything if you say hi?

shy bane
#

@client.command()
async def poop(ctx):
await ctx.send(f's')
edit ctx.send(f's2')

slate swan
#

They want the bot to reply with "hello" then edit it to "hi"

shy bane
#

like this but this will work

#

like edit the ctx.send

tough wagon
#

no

slate swan
#

@tough wagon should we spoonfeed

#

?

shy bane
#

someone?

tough wagon
slate swan
shy bane
#

yes?

slate swan
#

@tough wagon will make the code then I will explain how it works

shy bane
#

ok

tough wagon
slate swan
shy bane
#

m?

tough wagon
#

m is name of variable (message)

shy bane
#

wait i'am trying it

#

ok

slate swan
#

At least I don't do irrelevant spoonfeed

calm vortex
slate swan
#

Spoonfeeding clearly shows you can't help

shy bane
#

oh thank you

slate swan
slate swan
slate swan
#

How about no

#

And just say here

slate swan
tough wagon
slate swan
#

I'm probably more helpful than you here

tough wagon
#

ok bye

slate swan
boreal ravine
#

imagine fighting in a python server?

calm vortex
kindred epoch
slate swan
boreal ravine
#

@calm vortex thought u were the server owner 😗

tough wagon
slate swan
#

i can't explain without an actual example

#

thats why i always carry a notebook an a pen/pencil

#

theres no need to be this mad about it@slate swan

hasty iron
#

what even are you guys mad about

#

this seems super dumb

slate swan
#

it is anyways

#

And can you explain why you need to ping when you clearly have seen I've moved away ASpepega

tough wagon
#

@hasty iron agreed 888%

slate swan
#

You're just bringing it back up again by doing so

hasty iron
#

drop it

slate swan
#

Yeah already realized that

slate swan
hasty iron
#

if somebody is being annoying, report them to modmail or something

slate swan
#

No thank you

slate swan
#

People can change their behavior and spoonfeeding issues by themselves without having a mod to intervene

boreal ravine
#

stop

calm vortex
#

They were clearly intending to explain what the code does, it's their choice to send the code.

kindred epoch
#

why we dont recommend spoonfeeding is they dont care about the explanation, they just copy paste the code.

slate swan
#

Even if there was an explanation, people don't read it

slate swan
hasty iron
#

dude can you guys seriously drop it

calm vortex
calm vortex
outer ridge
calm vortex
#

I already said alright

slate swan
#

i apreciate your understanding but its not worth it anymore

fallow sage
#

how the fuck has a fight broken out in the discordpy channel

slate swan
tough wagon
#

stop word is like... 999999 ping

marsh depot
#

Hi, im trying to make the bot send two Embeds in the same message, but when i try it the terminal sen me this error :

'tuple' object has no attribute 'to_dict'

An i have this on my code
await ctx.send(embed=(EmbedPing, EmbedAnuncio))

I try it to make embed= EmbedPing + EmbedAnuncio but nothing

Anyone can help me?

slate swan
#

You can't send multiple embeds in v1.7.3

#

Update to 2.0.0 or don't send multiple embeds in a single message

tough wagon
#

and not () it is []

kindred epoch
slate swan
#

embeds=... u mean?

tough wagon
#

!d discord.abc.Messageable.send

unkempt canyonBOT
#

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

Sends a message to the destination with the content given.

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

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

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

embed=list[discord.Embed]

slate swan
kindred epoch
#

yea you need to update to 2.0

slate swan
#

Missing the 's' though

kindred epoch
#

lol...

tough wagon
#

to update

kindred epoch
#

embeds (List[Embed]) –

A list of embeds to upload. Must be a maximum of 10.

New in version 2.0.

slate swan
#

But yeah

tough wagon
kindred epoch
#

lol

ripe jackal
#

Hello, I'm trying to create leveling system, but I'm not doing something right. Yes, I know JSON is bad, but I can't make it with an actual database. The problem is that when I level up (at the first message I send), it tells me that I leveled up to 0 level and I can't level up to level 1. I have an error. Please tell me what to do! This is the code: python @client.event async def on_message(message): with open('users.json','r',encoding='utf8') as f: user=json.load(f) try: with open('users.json','w',encoding='utf8') as f: user[str(message.author.id)]['xp']=user[str(message.author.id)]['xp']+1 lvl_start=user[str(message.author.id)]['level'] lvl_end=user[str(message.author.id)]['xp']**(1.5/4) if lvl_start <lvl_end: user[str(message.author.id)]['xp']= user[str(message.author.id)]['level']+1 lvl=user[str(message.author.id)]['level'] await message.channel.send(f"{message.author.mention} has leveled up to {lvl}!") json.dump(user,f,sort_keys=True,indent=4,ensure_ascii=False) return json.dump(user,f,sort_keys=True,indent=4,ensure_ascii=False) except: with open('users.json','w',encoding='utf8') as f: user={} user[str(message.author.id)]={} user[str(message.author.id)]['level']=0 user[str(message.author.id)]['xp']=0 json.dump(user,f,sort_keys=True,indent=4,ensure_ascii=False)
This is the error: raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

kindred epoch
#

@marsh depot what are you trying to send?

kindred epoch
ripe jackal
kindred epoch
#

using json as a database sounds intersesting? anyways, postgres/sql is a recommened db so might as well learn how to use those.

tough wagon
#

NoNoNoNo, 3 openings of json file in one event, super low speed, omfg

slate swan
#

Been dealing with this error for a few days and I'm losing my mind.

@tasks.loop(seconds=10)
async def delete_keywords():
  keywords = ['asd']

  guild = bot.get_guild(891589851110051860)
  db_func = discord.utils.get(guild.channels, name="general")
  channel_id = db_func.id
  db_user = bot.get_channel(channel_id)
  messages = discord.utils.get(await db_user.history(limit=100).flatten())

  for message in messages:
    check = any(keywords in message.content for keywords in keywords)
    if check == True:
      msg_obj = await message.channel.fetch_message(message.id)
      await msg_obj.delete()

delete_keywords.start()

The error I'm getting is in line 6, NoneType object has no attribute channels. Yes, I've checked - the guild ID is correct and the bot is in the guild I'm trying to get and yet it doesn't work. Please help.

ripe jackal
slate swan
#

json is commonly used for static data since it doesnt fare as well as a database when filtering, searching and generally managing data. Also, it will become increasingly slower when doing dictionary lookups as your bot userbase grows

ripe jackal
#

what should I do?

tough wagon
slate swan
#

learn sql

ripe jackal
#

:/

slate swan
#

I understand the error and have tried to fix it but I can't

kindred epoch
#

use fetch_guild as @tough wagon said

slate swan
#

ok lemme try

hasty iron
#

no dont

tough wagon
hasty iron
#

you have to add bot.wait_until_ready inside your task

#

you’re trying the get from cache before it’s filled

#

!d discord.Client.wait_until_ready

unkempt canyonBOT
#

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

Waits until the client’s internal cache is all ready.
marsh depot
tough wagon
#

oh yesss i always forgot about that ready problems

slate swan
tough wagon
slate swan
#

at the end?

hasty iron
#

guess

slate swan
#

I'd guess yeah

hasty iron
#

what

tough wagon
#

nope

hasty iron
#

think about it

#

you have to wait before getting

slate swan
#

one of the reasons why I love c#

tough wagon
#

one of the reasons why I hate c#

calm vortex
slate swan
#

defining variables before using them is pretty neat though

slate swan
#

is there a way to cancel a command if something happens?

slate swan
#

oh yeah lmao

tough wagon
#
if statement:
    return```
slate swan
#

i forgor 💀

tough wagon
slate swan
#

Sending two separate embeds is a solution

pliant nacelle
#

guys how i can host my bot 24/7 free ?

slate swan
#

Take a look at this

pliant nacelle
#

rdp ?

brisk fiber
#

it's also possible to host a smallish bot on a raspberry pi

calm vortex
#

I just realised it works, embed limit including description and other things is 6000, two embeds in a single message with only their descriptions fully filled means 8192, so it can work if the second embed's description is sufficiently less.

brisk fiber
# pliant nacelle how

hook a pi up to power and ethernet, send your bot code to it, run the file, sit back and enjoy

slate swan
#

Please help, i want options and then a argument input, how can i do that?

slate swan
kindred epoch
slate swan
#

nah thats not the thing i wanted

tawdry perch
#

Isn't that what you asked for?

slate swan
#

/play option1;option2;option3 msg:

#

@kindred epoch

kindred epoch
slate swan
#

...

#

I want slash with it

#

._.

kindred epoch
#

you can put select menus in slash commands

slate swan
#

I thought you mean the components function 👀

#

but how i do that?

kindred epoch
ripe jackal
#

Hello, can someone tell me what to do?python @client.event async def on_message(ctx,msg): user=msg.author mbed=discord.Embed(title=f"{msg.author} has been warned", description="**Reason:** Bad word usage", color=discord.Color.green()) ebed=discord.Embed(title=f"**You** have been warned from _**Icy Area**_", description="**Reason:** Bad word usage", color=discord.Color.green()) for word in words: if word in msg.content: await msg.delete() await client.process_commands(msg) await ctx.send(embed=mbed) await user.send(embed=ebed)

TypeError: on_message() missing 1 required positional argument: 'msg'```
slate swan
#

Bandwidth usage is reduced, and I'd guess resources saved

kindred epoch
slate swan
#

The documentation explains how to use it. Make requests (POST, GET, PATCH, ...) to the API following their documentation.

ripe jackal
slate swan
#

message.channel.send?

kindred epoch
#

await message.channel.send

pliant gulch
#

That's why you connect to the gateway

#

To receive message_create events

slate swan
#

Exactly

ripe jackal
#

Thank you so much ❤️ @slate swan , @kindred epoch

#

and sorry for the tag

pliant gulch
#

There's a gateway topic in the docs

slate swan
pliant nacelle
#

how i can host my bot for free 24/7 ?

ripe jackal
slate swan
#

how can I do a select menus with slash commands ;-;

pliant gulch
pliant nacelle
pliant gulch
slate swan
pliant nacelle
pliant gulch
unkempt canyonBOT
#
coroutine async-with ws_connect(url, *, method='GET', protocols=(), timeout=10.0, receive_timeout=None, auth=None, autoclose=True, autoping=True, heartbeat=None, origin=None, ...)```
Create a websocket connection. Returns a [`ClientWebSocketResponse`](https://aiohttp.readthedocs.io/en/stable/client_reference.html#aiohttp.ClientWebSocketResponse "aiohttp.ClientWebSocketResponse") object.
calm vortex
pliant nacelle
deft hill
#

Im using discord.py. What is a good db to learn and use and where can I learn it?

pliant gulch
#

It is public https://github.com/an-dyy/Lefi

#

Its only partially documented though

brisk fiber
#

make sure whatever library you use is asynchronous

vague grove
#

hello, Im running into an issue with my leaderboard command, its putting multiple lines as 1 person (as seen in the pic below).. here is the code for the command:

@client.command(aliases = ["lb"])
async def leaderboard(ctx, x=5):
    users = await get_bank_data()
    leader_board = {}
    total = []
    for user in users:
        name = int(user)
        total_amount = users[user]["wallet"]
        leader_board[total_amount] = name
        total.append(total_amount)

    total = sorted(total,reverse=True)

    em = discord.Embed(title = f"leaderboard: " , description = f"Top {x} credit leaderboard",color = discord.Color(0xfa43ee))
    index = 1
    for amt in total:
        id_ = leader_board[amt]
        member = client.get_user(id_)
        name = member.name
        em.add_field(name = f"{index}. {name}" , value = f"{amt}",  inline = False)
        if index == x:
            break
        else:
            index += 1

    await ctx.send(embed = em)

and my json file looks like this {"66008908772534677": {"wallet": 69, "bank": 4}}

pliant gulch
#

Hence documentation

deft hill
deft hill
final iron
#

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.

slate swan
#

Well since you've sent this I feel like we need to send the Heroku one too

#
You should not use Heroku to host your bot.

- Bots are not what the platform is designed for. Heroku is designed to provide web servers (like Django, Flask, etc). This is why they give you a domain name and open a port on their local emulator.

- Heroku's environment is heavily containerized, making it significantly underpowered for a standard use case.

- Heroku's environment is volatile. In order to handle the insane amount of users trying to use it for their own applications, Heroku will dispose your environment every time your application dies unless you pay.

- Heroku has minimal system dependency control. If any of your Python requirements need C bindings (such as PyNaCl binding to libsodium, or lxml binding to libxml), they are unlikely to function properly, if at all, in a native environment. As such, you often need to resort to adding third-party buildpacks to facilitate otherwise normal CPython extension functionality. (This is the reason why voice doesn't work natively on heroku.)

- Heroku only offers a limited amount of time on their free programme for your applications. If you exceed this limit, which you probably will, they'll shut down your application until your free credit resets.
#

Here we go

inland venture
#

import discord
import random
from discord.ext import commands

client = commands.Bot(command_prefix='*')

@client.event
async def on_ready():
await client.change_presence(status=discord.Status.idle, activity=discord.Game('*help'))
print('We have logged in as {0.user}'.format(client))

@client.command()
async def kick(ctx, member : discord.Member, *, reason=None):
await member.kick(reason=reason)

@client.command()
async def ban(ctx, member : discord.Member, *, reason=None):
await member.ban(reason=reason)

#

I got no errors, but it's not letting me kick the user

slate swan
#

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

pliant nacelle
slate swan
#

Make sure you read it

inland venture
#

?

final iron
slate swan
#

mmmh no

final iron
#

yes

slate swan
#

no

jade jolt
#

lol no

slate swan
#

There's an argument member

#

For !kick @User

jade jolt
slate swan
#

And it will kick the user

slate swan
jade jolt
#

np

pliant nacelle
#

@slate swan dm your server bot

waxen granite
#

error 1: await guildchan.send(f"Bye bye **{guild.name}**.") AttributeError: 'NoneType' object has no attribute 'send'

#

error 2: File "D:\Discord Bot\GitHub\ecrpgbot1v2.0\cogs\owner.py", line 94, in leaveserver await newchan.send("Bye Bye nabs") File "C:\Users\Endomorph\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\abc.py", line 1065, in send data = await state.http.send_message(channel.id, content, tts=tts, embed=embed, File "C:\Users\Endomorph\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\http.py", line 248, in request raise Forbidden(r, data) discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions

slate swan
#

Guild might have no system channel

jade jolt
#

^^^

slate swan
#

And therefore returns None

waxen granite
#

ye thats why i did the try thing

slate swan
waxen granite
#

but it is sending the msg

jade jolt
#

lol

inland venture
#

do u know how to make your bot send 1 message all in once

#

kinda like wall text

slate swan
#

?

jade jolt
#

explain better lol

slate swan
#

Bot sending 1 message all in once:

await ctx.send("a message all in once")
#
    async def nicknamewhitelist(self, ctx):
        data = db.find_one({ "guild_id": ctx.guild.id })['nicknamewhitelist']
        embed=discord.Embed(title='Nickname Whitelsit', description=f"To add a role to the nickname whitelist, invoke `{ctx.prefix}nwl add @role`. To remove a role to the nickname whitelist, invoke `{ctx.prefix}nwl del @role`.\n")
        for id in data:
            role = self.client.get_role(id)
        embed.description += f"{role} | {role.mention} [`{role.id}`]\n"
        await ctx.send(embed=embed)```

`UnboundLocalError: local variable 'role' referenced before assignment`
#

You might want to indent the line in the for loop, and not outside

#

aight ill try

#

And get_role only exists on a Guild object

slate swan
#

would be nice if you named bot correctly

waxen granite
#

Can we customize the bot role (the self designated one) upon guild join?

slate swan
#

and there's a syntax error in on_ready

waxen granite
#

Setting its colour etc

slate swan
#

lol

final iron
#

Im having an issue with tasks.loop not working

#

Its just not looping

#

Nothing else is using an event loop

slate swan
#

is there a way to check if a certain user name and discriminator is taken or not

ripe jackal
#

Hey, can someone tell me why the welcome commands does not work now?

ripe jackal
slate swan
#

because you didn't provide any code or error

ripe jackal
#
@client.event
async def on_member_join(member):
   channel= client.get_channel(892136447535120385)
   channel.send(f"{member.name} has joined")```
#

no error given

#

:/

slate swan
#

you forgot await

#

and intents maybe

ripe jackal
#

did not work :/

slate swan
#

nice

#

air me

#

what the heck am I witnessing

slate swan
#

it is

#

it's just he can't get the member's name

#

if he doesn't have intents enabled

#

intents

ripe jackal
#

i have them enabled

slate swan
#

and he proceeds to tell me "no work man"

ripe jackal
#

intents=discord.Intents.all()

slate swan
#

And on dashboard?

#

and your bot constructor?

ripe jackal
#

i think yes

slate swan
#

Well you should be sure

#

what are some discord.py forks that you'd recommend?

#

what for

#

Heard about pycord, nothing else

#

So can't really recommend as it's the only one I've heard about

slate swan
#

I'm just gonna wait for dpy

#

they can't just leave it like that

slate swan
#

there's no way

#

Probably going to wait a long time to be honest

#

I already moved library and language when the updates became so slow

#

So the cease of development doesn't really affect me

slate swan
#

who said it's gonna be danny

ripe jackal
#

it does not work, i have enabled everything on my bot constructor or whatever you call it

slate swan
#

Maybe not him but someone else, but I really doubt as nobody got really interested in it either way

slate swan
ripe jackal
#

wdym dashboard? discord dev portal?

slate swan
#

I'm not gonna say what the problem is

slate swan
ripe jackal
#

yes

ripe jackal
#

the bot does not work and it does not give any error

slate swan
#

do you have an error handler?

#

if yes, disable it

ripe jackal
#

yes, but only for commands, not events

slate swan
slate swan
ripe jackal
slate swan
#

if you used the event

pliant gulch
#

The error handler your talking about is only dispatched in commands when they errored

#

Event error are in on_error

slate swan
#

hm

ripe jackal
#

exactly

slate swan
#

well that's not really helpful then

pliant gulch
#

Bot being your commands.Bot instance

ripe jackal
#

on my on_ready thing?

#

event*

pliant gulch
#

Sure, then send it here

slate swan
#

got it working tho

ripe jackal
#

nothing shows up :/

hardy yoke
pliant gulch
#

print(dict(client.intents))

ripe jackal
#

sorry, did not understand you

pliant gulch
#

You don't have members intent

slate swan
ripe jackal
pliant gulch
hasty iron
final iron
#

Im having an issue with tasks.loop not looping. Nothing else is using an event loop and I wrote it properly

pliant gulch
#

Not a intent

hardy yoke
ripe jackal
pliant gulch
#

!intents

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
#

if you want to be set you can do intents=discord.Intents.all()

final iron
# hasty iron ?

Its not doing anything. Not looping and not sending anything

hasty iron
#

ok, and what are we supposed to do

#

you didn’t even send ur code

ripe jackal
slate swan
#

yep, that's really frustrating in these situations

ripe jackal
#

-_- tysm

slate swan
#

the "no error" aswell

ripe jackal
#

but it doesn't show any error

final iron
hasty iron
#

that’s still not enough for us to do anything

final iron
#

As i've stated before it literally does nothing

pliant gulch
#

Where are you starting the task

hasty iron
#

can you send your whole code

slate swan
waxen granite
covert igloo
#

I keep getting this error in heroku but the bot runs fine when i run it on my computer

slate swan
#

put discord_slash in your requirements file

#

or stop using heroku for your bot

covert igloo
#

what else should i use

#

that is free

slate swan
#

!vps

#

meh

#

.

covert igloo
#

is it free

slate swan
#

did you read it

#

There are no reliable free options for VPS hosting.