#discord-bots

1 messages · Page 543 of 1

soft radish
#

like it'll update without shutting down the bot and running it

boreal ravine
#

try googling "how to restart a python file without shutting it down" im on mobile atm cant do much you should see a stackoverflow page

slate swan
#

reload the COGS file

boreal ravine
#

he didnt say it was a cog file

covert igloo
#

dead man idk whats up with this

#

@boreal ravine whats the pip command for utils let me try to reinstall it

slate swan
boreal ravine
covert igloo
#

is it discord-utils or discord.utils

boreal ravine
#

!pypi discordutils

unkempt canyonBOT
covert igloo
slate swan
#
@client.command()
async def ping(ctx):
	await ctx.send('Pong! {round(client.latency * 1000)}ms')```
#

This doesn't show the bot latency... Just responds with Pong! {round(client.latency * 1000)}ms

graceful gorge
#

hello

bright palm
graceful gorge
#

how to sent msg using bot

slate swan
stable delta
#

are you using discord.ext?

#

is it under an event decorator?

graceful gorge
graceful gorge
graceful gorge
#

but senting msg

stable delta
#

aight so

#

can you show me your code? (don't send the token btw)

stable delta
#

cause there are many ways to have the bot send a message

graceful gorge
#

ik

#

Import Discord Package

import discord

Client (our bot)

client = discord.Client()

async def on_ready():
# Do Stuff
general_channel = client.get_channel(877778689650200579)
await general_channel.sent('helloooooooooo')
#run the client on discord server
client.run('its my token')

#

see it

stable delta
#

aight so

valid perch
#

sent -> send

stable delta
#

.send

#

but I would recommend using discord.ext instead of just discord, it's much easier to use

graceful gorge
stable delta
#

and it provides more capabilities

graceful gorge
graceful gorge
stable delta
#

could you send your code again please but this time using a code block?

graceful gorge
#

Import Discord Package

import discord

Client (our bot)

client = discord.Client()

async def on_ready():
# Do Stuff
general_channel = client.get_channel(877778689650200579)
await general_channel.send('helloooooooooo')
#run the client on discord server
client.run('TOKEN')

graceful gorge
stable delta
graceful gorge
#

ok

stable delta
#

e.g.
```
print("Hello World")!
```
translates to

print("Hello World!")
graceful gorge
#

ok

#

`# Import Discord Package
import discord

Client (our bot)

client = discord.Client()

async def on_ready():
# Do Stuff
general_channel = client.get_channel(877778689650200579)
await general_channel.send('helloooooooooo')
#run the client on discord server
client.run('TOKEN')`

graceful gorge
#

;p;

#
import discord
# Client (our bot)
client = discord.Client()

async def on_ready():
    # Do Stuff
    general_channel = client.get_channel(877778689650200579)
    await general_channel.send('helloooooooooo')
#run the client on discord server   
client.run('TOKEN')```
stable delta
slate swan
#

@client.event

stable delta
#

I can't believe I didn't see that lol

graceful gorge
slate swan
#

Add that at the top of your func

graceful gorge
graceful gorge
#

can you tell

slate swan
#

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

graceful gorge
slate swan
#

By learning python

slate swan
#

I'm so sick of people like you who start with a discord bot when you clearly have 0 knowledge the language

graceful gorge
#

thik se bolo

slate swan
#

You don't

stable delta
#

the function is the def that you put in your code

#

so async def on_ready() would be your function

slate swan
#

You haven't even bothered looking at the docs, there's an example literally in the docs

stable delta
#

Kraots said to put the decorator over the function

#

which means you need to put @client.event on top of async def on_ready():

slate swan
#

!d discord.Client.event

unkempt canyonBOT
#

@event```
A decorator that registers an event to listen to.

You can find more info about the events on the [documentation below](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events).

The events must be a [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine "(in Python v3.9)"), if not, [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.9)") is raised.

Example

```py
@client.event
async def on_ready():
    print('Ready!')
slate swan
#

It's literally in the docs

graceful gorge
#

lol

#

wth

#

wo gayab hogaya

slate swan
#

¯\_(ツ)_/¯

graceful gorge
#

it worksssssssssss

graceful gorge
#

lol

slate swan
#

English

graceful gorge
#

Ignoring exception in on_ready
Traceback (most recent call last):
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "c:\Users\Admin\Desktop\python\real wale\my bot.py", line 9, in on_ready
await general_channel.send('@deft sphinx he i am your big fan')
AttributeError: 'NoneType' object has no attribute 'send'

#

now working

meager whale
#
@client.command()
@commands.has_role("Owner")
async def giveaway(ctx):
    await ctx.send("Let's start with this giveaway! Answer these questions within 15 seconds!")

    questions = ["Which channel should it be hosted in?", 
                "What should be the duration of the giveaway? (s|m|h|d)",
                "What is the prize of the giveaway?"]

    answers = []

    def check(m):
        return m.author == ctx.author and m.channel == ctx.channel 

    for i in questions:
        await ctx.send(i)

        try:
            msg = await client.wait_for('message', timeout=15.0, check=check)
        except asyncio.TimeoutError:
            await ctx.send('You didn\'t answer in time, please be quicker next time!')
            return
        else:
            answers.append(msg.content) 
slate swan
#

How do I make sudobot online?

#

How do i make it so the author cannot ban himself with ban command? I created something so when the author tries to do this bot sends you cannot ban yourself but now bot is banning the author and then sending the message

slate swan
inland venture
#
    if user_message.lower() == '*specs':
        embed = discord.Embed(title="Sunflower Duck's PC specs", url="https://www.youtube.com/watch?v=dQw4w9WgXcQ",
                              description="SSD: M.2 1000GB Hard Drive MOBO: B460M Pro Vdh Wifi GPU: Intel UHD 630 Case: H510 Elite RAM: 16GB CPU: Intel core i5 10400",
                              color=0xFF5733)
        await message.channel.send(embed=embed)
        return
#

how do i put specsin ech rows

#

each rows*

stable delta
slate swan
#

Do u know the bot or not

lusty swallow
slate swan
#

Whoah

#

Never realized stop() exists

#

I'm so nooby

lusty swallow
#

stop() doesn't exists

slate swan
#

Oh

#

Hey I meant sukpbot not sudobot

slate swan
distant salmon
#

Hello guys!
I'm using imports from discord and discord_components libraries. On clicking any button I'm getting Interaction failed error. When using buttons I don't have any ability to edit the message containing these buttons, due to how my program works. Is there a way to get around this and get rid of this error without editing the initial message containing buttons?

fading harness
#

i want to get the author's voie channel id

unkempt canyonBOT
#
Naw.

No documentation found for the requested symbol.

manic wing
fading harness
manic wing
slate swan
#

You'd have to do for each individual class

undone lodge
#

.

manic wing
slate swan
#

Yeah

soft radish
#

whats the package name of utils.util?

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.

boreal ravine
unkempt canyonBOT
soft radish
boreal ravine
soft radish
soft radish
boreal ravine
soft radish
#
from utils.util import clean_code```
boreal ravine
#

read the error theres no module called "utils.utils"

soft radish
boreal ravine
#

it's your code isn't it

#

how am I supposed to know what module is utils.utils lol

slate swan
#

This happens when copy paste commands, people don't even know they're supposed to copy the utils ¯\_(ツ)_/¯

boreal ravine
#

¯_(ツ)_/¯

lament mesa
#

!d discord.utils.escape_markdown

unkempt canyonBOT
#

discord.utils.escape_markdown(text, *, as_needed=False, ignore_links=True)```
A helper function that escapes Discord’s markdown.
swift field
#
@bot.command('atlas')
async def on_voice_state_update(ctx):
    with sr.Microphone() as source:
        ctx.send('listening...')
        voice = listener.listen(source)
        command = listener.recognize_google(voice)
        command = command.lower()
    await ctx.send(command)

@bot.event()
async def run_atlas():
    if 'time' in command:
        time = datetime.datetime.now().strftime('%I:%M %p')
        ctx.send('Current time is ' + time)
    elif 'stop' in command:
        ctx.send('Shutting down...')
        ctx.voice_client.disconnect()
        exit()
    else:
        pass
    await ctx.send('listening...')
#

anyone know why for the bot.event part the ctx and command i snot defined...?

#

nvm i go tit

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

what does self.view.embed.description.split("\n")[0] do?

slate swan
dusk pumice
#

What's the error on my bot...

#

Ah... I made a foolish mistake...

#

Sorry

maiden fable
#

Lol

slate swan
#

guys i need some help rq
I was making a server prefix command then I ran into a slight issue

def get_prefix():
  paths = os.scandir("servers")
  for path in paths: 
    return

client = commands.Bot(command_prefix=getprefix(), intents=intents)```

my server directory saves the ids of guilds, how exactly to I send a guild object or id to my function. 
`Note: i'm not asking about how to give my function arguments i already know how to do this`
#

example code to understand what im trying to find here

def get_prefix(guild):
  paths = os.scandir("servers")
  for path in paths: 
    if path.name == guild.id:
       return

client = commands.Bot(command_prefix=getprefix(guild), intents=intents)```
vocal plover
vocal plover
#

Oh and remember about dms; guild may be None

slate swan
#

ofc

#

my bot wont be doing dm commands for the time being but i'll keep that noted

velvet tinsel
#

guys

#

help me pls

gloomy quest
velvet tinsel
#
@commands.has_permissions(manage_messages=True)
async def mute(ctx, member: discord.Member, *, reason=None):
    guild = ctx.guild
    mutedRole = discord.utils.get(guild.roles, name="Muted")

    if not mutedRole:
        mutedRole = await guild.create_role(name="Muted")

        for channel in guild.channels:
            await channel.set_permissions(mutedRole, speak=False, send_messages=False, read_message_history=True, read_messages=False)
    embed = discord.Embed(title="muted", description=f"{member.mention} was muted ", colour=discord.Colour.light_gray())
    embed.add_field(name="reason:", value=reason, inline=False)
    await ctx.send(embed=embed)
    await member.add_roles(mutedRole, reason=reason)
    await member.send(f" you have been muted from: {guild.name} reason: {reason}"
#

How to make it so the owner can access this code

#

*can use this code

gloomy quest
#

if ctx.author == ctx.guild.owner: **rest of code**

velvet tinsel
#

tysm

gloomy quest
#

np

velvet tinsel
#

wait

#

where do I put the ctx

gloomy quest
#

wait

velvet tinsel
#

ok

gloomy quest
velvet tinsel
#

ok

#

?

gloomy quest
#
@commands.has_permissions(manage_messages=True)
async def mute(ctx, member: discord.Member, *, reason=None):
 if ctx.author == ctx.guild.owner:
    guild = ctx.guild
    mutedRole = discord.utils.get(guild.roles, name="Muted")

    if not mutedRole:
        mutedRole = await guild.create_role(name="Muted")

        for channel in guild.channels:
            await channel.set_permissions(mutedRole, speak=False, send_messages=False, read_message_history=True, read_messages=False)
    embed = discord.Embed(title="muted", description=f"{member.mention} was muted ", colour=discord.Colour.light_gray())
    embed.add_field(name="reason:", value=reason, inline=False)
    await ctx.send(embed=embed)
    await member.add_roles(mutedRole, reason=reason)
    await member.send(f" you have been muted from: {guild.name} reason: {reason}")```
plush geode
#

@gloomy quest dont spoon feed lol

velvet tinsel
#

thx

#

what about adding reactions? And how to make it so that when reacted, it would do something?

boreal ravine
#

hm

#

!d discord.ext.commands.Bot.wait_for

unkempt canyonBOT
#

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

Waits for a WebSocket event to be dispatched.

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

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

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

This function returns the **first event that meets the requirements**...
boreal ravine
velvet tinsel
#

ok

#

thx

slate swan
#

Okay so, my check function is not working as intended, its supossed to check if a message was sent by the orginal author

         def check(m):
            return m.author == message.author
         try:
          msg = await client.wait_for("on_message", check=check,timeout=15)
         except asyncio.TimeoutError:
           await message.channel.send("Took too long to response")
           return
         else:```

Ik the reason why its not working, something to do with `m.author` not being the proper attrbute or smth in `return m.author == message.author`. I just have no clue how to fix this.
#

and this isn't exactly helping

visual island
boreal ravine
#

^

boreal ravine
slate swan
#

oh lmao

#

i forgot that its not the same names

#

thx

visual island
boreal ravine
#

hmm

slate swan
#

Basically all events

visual island
#

yeah, your custom event also works

slate swan
#

If you look a lil' in the docs you'll find them listed on after another

gloomy quest
#

and dont ping for not answering

slate swan
slate swan
#

Where can I promote my friends server

reef shell
slate swan
#

Oh ok

#

Lol

slate swan
#

yw

astral fossil
#

I still dont get how to use "DISCORD_SLASH" module. It seems does not work at all

boreal ravine
#

did you read the docs first? or the examples?

astral fossil
#

Yes still doesn't work

unkempt canyonBOT
#

Hey @astral fossil! I noticed you posted a seemingly valid Discord API token in your message and have removed your message. This means that your token has been compromised. Please change your token immediately at: https://discordapp.com/developers/applications/me

Feel free to re-post it with the token removed. If you believe this was a mistake, please let us know!

errant shuttle
#

Hey, I wanna access a function from a different folder. How do I do it?
Function folder (Repl.it)
Root directory/main.py
The folder I want to access it from (Repl.it)
Root directory/modules/help/embeds/help_command_embeds.py
What do I do?

astral fossil
#
from discord import Client, Intents, Embed
from discord_slash import SlashCommand, SlashContext

bot = Client(intents=Intents.default())
slash = SlashCommand(bot)

@slash.slash(name="test")
async def test(ctx: SlashContext):
    embed = Embed(title="Embed Test")
    await ctx.send(embed=embed)

bot.run("Oof")
visual island
#

wait no

errant shuttle
visual island
errant shuttle
visual island
#

cycle import error thing

errant shuttle
visual island
#

for?

boreal ravine
#

from main import function

errant shuttle
boreal ravine
#

whats the error?

astral fossil
errant shuttle
boreal ravine
astral fossil
boreal ravine
errant shuttle
visual island
errant shuttle
#

@boreal ravine it is for custom prefix command

Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/home/runner/Efendo-Bot-SRC/server.py", line 11, in run
    app.run(host='0.0.0.0',port=8080)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/flask/app.py", line 920, in run
    run_simple(t.cast(str, host), port, self, **options)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/werkzeug/serving.py", line 1010, in run_simple
    inner()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/werkzeug/serving.py", line 950, in inner
    srv = make_server(
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/werkzeug/serving.py", line 782, in make_server
    return ThreadedWSGIServer(
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/werkzeug/serving.py", line 688, in __init__
    super().__init__(server_address, handler)  # type: ignore
  File "/usr/lib/python3.8/socketserver.py", line 452, in __init__
    self.server_bind()
  File "/usr/lib/python3.8/http/server.py", line 138, in server_bind
    socketserver.TCPServer.server_bind(self)
  File "/usr/lib/python3.8/socketserver.py", line 466, in server_bind
    self.socket.bind(self.server_address)
OSError: [Errno 98] Address already in use
172.18.0.1 - - [18/Oct/2021 12:20:22] "GET / HTTP/1.1" 200 -
astral fossil
visual island
errant shuttle
visual island
errant shuttle
#

idk why i am getting that

visual island
#

show code

boreal ravine
astral fossil
errant shuttle
# visual island show code

root/main.py

from nextcord import *
from nextcord.ext import commands

def get_prefix(client, message):
    with open('prefixes.json', "r") as prefix_file:
        prefixes = json.load(prefix_file)

    return prefixes[str(message.guild.id)]

client = commands.Bot(
    command_prefix=get_prefix,
    strip_after_prefix=True,
    case_insensitive=True,
)

I also added an (underscore) init file.
root/modules/help/embeds/embed.py

from main import get_prefix
errant shuttle
boreal ravine
#

what IDE are you using?

errant shuttle
boreal ravine
#

Ah.

errant shuttle
# visual island show your server.py
from flask import Flask
from threading import Thread

app = Flask('')

@app.route('/')
def home():
    return "Webste for bot"

def run():
  app.run(host='0.0.0.0',port=8080)

def keep_alive():
    t = Thread(target=run)
    t.start()

It never gave me this error before

boreal ravine
#

use a proper ide replit gives import errors sometimes

errant shuttle
boreal ravine
errant shuttle
slate swan
slate swan
#

Hmm

#

It worked for me

gaunt ice
#

hlo

#

guys

boreal ravine
#

👋

errant shuttle
gaunt ice
#

i need help to make a bot

#

like it needs a verification system

slate swan
gaunt ice
#

how do u do that

boreal ravine
gaunt ice
#

like i make a random 3 digit number

gaunt ice
ionic wadi
#

Can someone help me? My hole bot and all functions just stopped working, I tried without the on)message event and still nothing works

gaunt ice
slate swan
ionic wadi
#

Its like 3000 lines

gaunt ice
ionic wadi
#

Theres no error

astral fossil
#
from discord import Intents, Embed
from discord.ext import commands
from discord_slash import SlashCommand, SlashContext

bot = commands.Bot(intents=Intents.default(), command_prefix='??')
slash = SlashCommand(bot)

@slash.slash(name="test")
async def test(ctx: SlashContext):
    embed = Embed(title="Embed Test")
    await ctx.send(embed=embed)

bot.run("lol")

It doesn't show error but it still don't show slash command

ionic wadi
#

just nothing works

slate swan
gaunt ice
#

but what i mean is like a verification system

errant shuttle
errant shuttle
boreal ravine
ionic wadi
#
@bot.listen()    
async def on_message(message):
    if message.author == bot:
        print("Hi")
    else:
        global author_msg_counts
        author_id = message.author.id
        curr_time = datetime.datetime.now().timestamp() * 1000
        if not author_msg_times.get(author_id, False):
            author_msg_times[author_id] = []
        author_msg_times[author_id].append(curr_time)
        expr_time = curr_time - time_window_milliseconds
        expired_msgs = [
            msg_time for msg_time in author_msg_times[author_id]
            if msg_time < expr_time
        ]
        for msg_time in expired_msgs:
            author_msg_times[author_id].remove(msg_time)
        if len(author_msg_times[author_id]) > max_msg_per_window:
            await message.channel.send(f"{message.author.mention} is gemute ivm meervoudig spam.")
            role = message.guild.get_role(861384357758238740)
            await message.author.add_role(role)
    if message.content in blacklist:
        await message.delete()
        await message.channel.send(f"{message.author} Dat woord is niet toegestaan.")
    if message.author.bot == False:
        with open('json/users.json', 'r') as f:
            users = json.load(f)
        await update_data(users, message.author)
        await add_experience(users, message.author, 5)
        await level_up(users, message.author, message)

        with open('json/users.json', 'w') as f:
            json.dump(users, f)```
boreal ravine
ionic wadi
#

I guess

odd pendant
#

process commands

ionic wadi
#

Doesnt fix it either

boreal ravine
boreal ravine
ionic wadi
#

Nope

gaunt ice
#

noo like a verify thing where u do verify cmd and the bot dms u message (the random 3 digit number) and the user shud send that random in the bot's dmsdigit number and the bot gives the verified role

manic wing
#

you dont process in listen

odd pendant
# boreal ravine y

because you need to process commands when you're using messages in on_message

slate swan
manic wing
#

listen is ddifferent to event

astral fossil
odd pendant
#

oh he's using listen my bad

boreal ravine
ionic wadi
#

But how do I fix it then 👀

boreal ravine
#

@ionic wadi idk how listen works but isnt it like this?

@bot.listen("on_message")
errant shuttle
gaunt ice
#

oof

boreal ravine
ionic wadi
#

Its not an command

boreal ravine
#

its an event

ionic wadi
#

and I use bot

gaunt ice
ionic wadi
#

Random number generator, save that to a variable and make the bot wait_for a response

#

and then check if message.content = variablename:
Code
else:
Code

hard pilot
#

how to integrate a embed in a listen command?

ionic wadi
hard pilot
#

yes but how haha

gaunt ice
#

u

#

hellp me

#

demm

gaunt fossil
#

z

errant shuttle
# gaunt ice can

um you shud use databases for a random number for each user and the number shud be 8 digit

gaunt ice
#

oh

#

oki

ionic wadi
#

File "/home/container/bot.py", line 155, in <module>
@bot.event()
TypeError: event() missing 1 required positional argument: 'coro'

#

Whut

slate swan
#

No ()

#

Remove them

#

It's just @bot.event

errant shuttle
ionic wadi
#

Still nothing In my bot works 😂

#

Shouldnt it be with an []

errant shuttle
ionic wadi
#

Instead of activity=activity()

errant shuttle
#

there is no []

boreal ravine
#

its a module error

visual island
#

its not

boreal ravine
#

hm

visual island
#

type should derives from ActivityType

#

not str

boreal ravine
#

nextcord.ActivityType then?

visual island
#

yes

boreal ravine
#

hm

slate swan
#

How can my bot check if it has permission to send message in that particular channel??

#

!d discord.abc.GuildChannel.permissions_for

unkempt canyonBOT
#

permissions_for(obj, /)```
Handles permission resolution for the [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") or [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role").

This function takes into consideration the following cases...
slate swan
#

And you can put as argument Guild.me

random sleet
#

this dont work. Pls help

slate swan
#

What doesn't work

visual island
slate swan
#

Just saying "this don't work" won't help

random sleet
slate swan
#

Do you by any chance have an on_message event?

#

And as kylee said, type hint the argument to an int

ionic wadi
#

How to fix this? (The hastebin is an error)

slate swan
#

Improper token has been passed.

#

Error says it all

#

Give a valid bot token

ionic wadi
#

Oh yeah forgot that I regenerated It

#

thanks

slate swan
visual island
#

you cant have check on events..

slate swan
#

The @commands.has_role doesn't work for events

#

Remove it

#

And you're missing await bot.process_commands(mesage)

random sleet
visual island
#

you can just do @bot.listen()

slate swan
#

You can get rid of the event anways

visual island
#

so you don't need process_commands

slate swan
#

Remove the !embed check and turn it into a command

#

And remove the entire event

visual island
#

yeah

terse owl
#

Botted a bot

#

Not by me

night bridge
#

wow

terse owl
#

I want to learn

night bridge
#

me too

terse owl
#

@night bridge this is my bot

#

But made by other

#

In money

#

Any coach

slate swan
#

How to check if the bot has send_message permission in a specific channel

terse owl
#

I need a code teacher Tell me from starting @slate swan

terse owl
#

And perm

slate swan
#

bruh

slate swan
#

I want to do it within code

terse owl
#

@slate swan

slate swan
terse owl
#

@slate swan what is all cmd of making a bot bassic cmd

slate swan
unkempt canyonBOT
#

permissions_for(obj, /)```
Handles permission resolution for the [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") or [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role").

This function takes into consideration the following cases...
slate swan
#

Returns permissions

#

Then you'd need to look at

#

!d discord.Permissions.send_messages

unkempt canyonBOT
graceful gorge
#

hello

#

lol

#

hi

drifting arrow
#

Hi

graceful gorge
drifting arrow
#

post your code here

graceful gorge
#

not working

#

when i am offline

drifting arrow
#

You trying to do a Text to speech thing?

graceful gorge
#

lol

graceful gorge
drifting arrow
#

idk how to do it offline but you can definitely do tts without needing gtts

drifting arrow
#

I thought it was to a discord channel.

#

Off memory, it's simply "channel.send("message", tts=True)"

#

channel can also be ctx

graceful gorge
#

not in bot

#

only in python

#

interpreter

boreal ravine
#

didnt we tell you to go learn python yesterday

drifting arrow
#

😮

dusk pumice
#

😮

#

Hello

random sleet
drifting arrow
dusk pumice
drifting arrow
slate swan
graceful gorge
drifting arrow
dusk pumice
#

UMM with discord vc?

graceful gorge
#
from playsound import playsound
playsound('helllo.mp3')
a=(input('type code:'))
if a == 'help':
    print('1 =  google')
    print('2 = text into word')
    print('3 = play song')

else:
    print('type ?Help')
    
a2 = input('type command:')
if a2 == '1':
    a3 = input('type website name:')
    import webbrowser
    webbrowser.open(a3)

else:
    print('wrong statement')

if a2 == '2':
    text=input('type here:')
    from gtts import gTTS
    tts=gTTS(text)
    tts.save('byee.mp3')
    from playsound import playsound
    playsound('byee.mp3')

else:
    print('wrong command')

if a2 == '3':
    from playsound import playsound
    playsound('song.mp3')
    print('playing song.')
    print('playing song..')
    print('playing song...')
    print('playing song....')```
#

look code

#

try it

#

need only = gtts

dusk pumice
#

WOW

graceful gorge
#

module

dusk pumice
#

google tts?

graceful gorge
graceful gorge
#

but

graceful gorge
#

in module

graceful gorge
dusk pumice
#

Like telling something..

dusk pumice
drifting arrow
#

I like this ```py
if a2 == '3':
from playsound import playsound
playsound('song.mp3')
print('playing song.')
print('playing song..')
print('playing song...')
print('playing song....')

No delay in the "playing song" so it'll print all 4 of those at the same time lol
graceful gorge
dusk pumice
#

I hope you make a cool bot

random sleet
graceful gorge
dusk pumice
dusk pumice
graceful gorge
graceful gorge
dusk pumice
drifting arrow
#

I was thinking about making an interface so I could send messages to a channel as my bot xD

dusk pumice
#

I wanna do it too

graceful gorge
dusk pumice
#

Umm

#

I can

terse owl
#

Hi

#

@terse owl

dusk pumice
#

But I can't right now

#

Can you teach me later?

drifting arrow
astral fossil
#

Sus

#

Slash command is depressing is a fact

random sleet
#

does someone have an event so the bots status shows how many servers the bot are in?

slate swan
#

There are no events like that

random sleet
slate swan
#

Make your own task loop

random sleet
random sleet
slate swan
#

Is it really that hard?

drifting arrow
dusk pumice
#

It is not that hard well

random sleet
slate swan
#

No...

#

Use your knowledge to add the code inside the loop

drifting arrow
#

output is:

[<Guild id=794837147068792862 name="Gnomeslayer's server" shard_id=0 chunked=True member_count=4>]
#

Up to you to figure out the rest

drifting arrow
#

cant tell if srs or being mean.

dusk pumice
#

It's not being mean

#

I'm just telling that code is nice

#

:|

drifting arrow
#

It is a nice piece of code

#

It does what it's meant to do

dusk pumice
#

:) cool

drifting arrow
#

If expanded upon, you could turn bot.guilds into an object and extract the id's and get other stuff.

#

Create an entire embed as well

hard pilot
#

how to get infos from a message of a user message into the bot ?

drifting arrow
hard pilot
#

when a user send a message i want too grab the nummbers or text

drifting arrow
boreal ravine
#

hm

hard pilot
drifting arrow
hard pilot
#

alright thanks made

willow vine
#

how do i start my task in a cog bot event on_ready

drifting arrow
boreal ravine
#

commands.Context has no attr content

drifting arrow
# boreal ravine no

well. idk then. i havent touched bots in a while. Thought I'd sit here for fun

boreal ravine
#

hm

drifting arrow
#

ctx is sent if it's part of a message. so you could do something like ctx.content or ctx.message.content

#

If it's in response to everytime a message is sent you'd need to do something different

boreal ravine
#

^

willow vine
drifting arrow
#
    @commands.Cog.listener()
    async def on_message(self, ctx):
        isbot = ctx.author.bot
        if isbot == False:
            messagecontent = ctx.content
            messageattachments = ctx.attachments
            if not messagecontent:
                await ctx.channel.send("Please attach some text.")
            else:
                await ctx.channel.send(f"Message content: {messagecontent}")
            if not messageattachments:
                await ctx.channel.send("Please attach an image.")
            else:
                await ctx.channel.send(f"Message content: {messageattachments}")
``` here is something I wrote a while ago to do something
willow vine
#

i want it to

kindred epoch
#

Cuz on_ready is called multiple times

#

And so it will start multiple times

drifting arrow
boreal ravine
#

and why is there ctx in an on message..?

#

on message only takes 1 param

#

hm

drifting arrow
#

and that param can be whatever i write.

boreal ravine
#

i guess so

drifting arrow
#

i believe documentation says "message"

boreal ravine
willow vine
kindred epoch
#

Bruh

drifting arrow
boreal ravine
#

init function yes

drifting arrow
#
    def __init__(self, client):
        print("[Cog] Loops has been initiated")
        self.client = client
        self.con = sqlite3.connect('bot.db')
        self.autounmute.start()
        #print("Started the autounmute function with an interval of 10 seconds.")

This is what I use for my auto-unmute function

willow vine
drifting arrow
#

Just keep your main discordbot file empty with nothing but the necessary code to load the bot

kindred epoch
drifting arrow
#

Move everything to cogs.

willow vine
random sleet
#

!d discord.Embed

drifting arrow
#

😮

kindred epoch
maiden fable
#

!botvat

unkempt canyonBOT
#

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

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

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

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

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

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

maiden fable
#

There's a tag now (:

reef quest
#

Anyone have discord music bot code

random sleet
#

how do i make a var with server members count

boreal ravine
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)
boreal ravine
unkempt canyonBOT
#

property member_count: int```
Returns the true member count regardless of it being loaded fully or not.

Warning

Due to a Discord limitation, in order for this attribute to remain up-to-date and accurate, it requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be specified.
reef quest
#

Anyone have discord music bot code

maiden fable
#

Breh

#

!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)
boreal ravine
unkempt canyonBOT
#

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

reef quest
#

Ok

slate swan
#

and you would have to write your own code anyways

#

this is like script kiddies

boreal ravine
#

script kiddy?

slate swan
#

"I'm a hacker"

boreal ravine
#

lmao

slate swan
#

with copied scripts

#

"I'm a programmer if you give me code"

boreal ravine
#

hm

dense swallow
#

no_pm=True means cmds won't work in dms right?

boreal ravine
#

whats no_pm though

dense swallow
#

I think it's no private msg

boreal ravine
#

you can do commands.guild_only

kindred epoch
dense swallow
maiden fable
boreal ravine
#

@dense swallow below the command decorator

dense swallow
#

Example?

#

in a cog

hasty iron
hasty iron
dense swallow
#
@commands.command(no_pm=True)
```??
hasty iron
#

but it doesn’t matter with dpy

boreal ravine
hasty iron
#

it’s not

boreal ravine
#

hm

dense swallow
#

It's not??

hasty iron
#

dude can you read, kayle told you to use commands.guild_only

dense swallow
#

:/

#

Does it used to be a thing, I wanna know

hasty iron
#

it wss never a thing

#

don’t come up with stuff and say "oh was it a thing"

dense swallow
#

Carl bot uses it in it's code (outdated)

boreal ravine
#

really

dense swallow
#

In GitHub

hasty iron
#

ok its outdated

terse owl
#

@dense swallow @hasty iron

dense swallow
#

Yeah I saw it from there

hasty iron
#

and you said it’s outdated

#

so why are you trying it

dense swallow
#

I asked if it ever existed

boreal ravine
#

not javascript

#

🗿

terse owl
#

Sry

zenith zinc
hasty iron
#

api banned lol

boreal ravine
zenith zinc
hasty iron
#

who knows

boreal ravine
#

read the error

hasty iron
#

you’re probably spamming the api in some way

dense swallow
#

Too many requests.. it says there

boreal ravine
#

literally says "too many requests"

zenith zinc
zenith zinc
#

what now

boreal ravine
#

🙁

hasty iron
#

it only lasts an hour dont worry

dense swallow
#

Were u re running ur bot many times?

boreal ravine
#

hm

hasty iron
zenith zinc
#

24/7

hasty iron
#

public host?

zenith zinc
#

cubic

hasty iron
#

oh

slate swan
#

@zenith zinc Happens to me too many times

#

I use replit

zenith zinc
#

i cant host on replit

slate swan
#

Why?

zenith zinc
#

idk im soo stuid

#

stuped

hasty iron
#

replit isn’t a host

zenith zinc
#

I KNOW

#

Replit is like VSC

slate swan
#

I just use it because my bot is not so big

zenith zinc
slate swan
hasty iron
zenith zinc
boreal ravine
#

wot

zenith zinc
#

What nowww not work hostt 😭

slate swan
#

Oh I remember something,

I made a bot which sends a particular message to all the channels....but the problem is that in some channels it does not have send_messages permission and so it stops executing whenever it encounter such channel....is there a way to bypass the channel...I tried using try except but pass just skip the loop and return does nothing....

zenith zinc
#

😦

#

type this in wait

slate swan
slate swan
zenith zinc
#

sorry

stark mountain
#

can someone help me?

zenith zinc
#

send_message

zenith zinc
stark mountain
#

i have a bot

zenith zinc
#

ok next

slate swan
stark mountain
#

the bot is coded to answer to a message with an manual input

zenith zinc
#

yes

boreal ravine
stark mountain
#

like that:

with open("token.txt", "r") as file:
    token = file.read().replace("\n", "")

import asyncio, discord, time

prefix = ">"

client = discord.Client()
    
@client.event
async def on_message(message):
    nachricht = input("Message: ")
    await message.channel.send(nachricht)
            
client.run(token)
zenith zinc
#

and

slate swan
boreal ravine
#

in discord

boreal ravine
slate swan
#

ok trying

stark mountain
#

like that(message was defined in console)

#

but it stops working after the second message

slate swan
stark mountain
#

but it works

#

somehow

#

kinda

slate swan
#

it should work

#

you just input something in console everytime

boreal ravine
#

^

slate swan
#

but why the hell in the console

#

why input btw?

stark mountain
slate swan
#

rp?

stark mountain
stark mountain
slate swan
#

....

#

I can see you're a beginner and client.wait_for would be too much

#

so idk

#

Instead use py await message.delete()

#

it will delete your message and send the message

stark mountain
#

thats not the point

boreal ravine
zenith zinc
boreal ravine
stark mountain
#

i used the message from me as sample

boreal ravine
slate swan
slate swan
# boreal ravine for what

Just I mean, The owner send the message and the bot will delete it and send the copy of the message

stark mountain
#

the message from bot are trough console

zenith zinc
slate swan
boreal ravine
slate swan
boreal ravine
#

just wait lol

zenith zinc
slate swan
boreal ravine
slate swan
#

<

zenith zinc
#

oooooooo

slate swan
slate swan
zenith zinc
#

I dead bye

stark mountain
# stark mountain thats not the point

i want to use the bot like this https://www.youtube.com/watch?v=23jCFhEyPoI

It ends badly.

Discord hackers are the most powerful beings to exist. Full power, complete control... nothing gets in their way.

╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝

follow these for a chance to be in my next video!
• Twitter - https://twitter.com/beluga1000
• Instagram - https://instagram.com/belug...

▶ Play video
boreal ravine
slate swan
#

below

boreal ravine
#

no

#

is below

slate swan
#

time < 24h

#

means below

#

peepoCry

boreal ravine
#

!e
e = 10
if e > 24:
print(1)
if e < 24:
print(2)

unkempt canyonBOT
#

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

2
boreal ravine
#

hm

slate swan
#

kayle....

boreal ravine
#

!e print(5>6)

unkempt canyonBOT
#

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

False
boreal ravine
#

See

slate swan
#

yeah that's what I said!

boreal ravine
#

thats what i said though

slate swan
#

wait what

#

i dont know but probably >24h

#

so you say it's above 24h

boreal ravine
#

I SAID THAT

boreal ravine
#

hm

slate swan
#

yeah I copy pasted it

#

is it really above 24h

boreal ravine
#

hm

stark mountain
#

hello

#

do you even notice me anymore

#

:c

slate swan
#

uh ye

stark mountain
#

i need help

#

like right now

slate swan
#

so what's the part that doesn't go

hasty iron
#

on_guild_join event

stark mountain
#

the bot crashes

hasty iron
#

!d discord.on_guild_join

unkempt canyonBOT
#

discord.on_guild_join(guild)```
Called when a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild") is either created by the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") or when the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") joins a guild.

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

it goes offline?

hasty iron
#

pick a random channel or whatever you want from Guild.text_channels and send a message to it

stark mountain
slate swan
#

huh

hasty iron
#

you would use it like any other event

#

huh what

#

you dont even have an on_ready event or something like that

#

that’s a bit contradictory

boreal ravine
#

envent

#

🗿

hasty iron
#

oh man

#

do you know basic python?

#

ok then continue learning

slate swan
hasty iron
#

you already have an event listener inside your code

#

it should be simple to know how to use it

boreal ravine
#

@slate swan its like making a function but its async and has a decorator

hasty iron
#

i have never used an event -> i have an event -> i have some events

#

so you did nothing

#

and you have no clue what to do

#

are you learning python or just how to use dpy

#

then why are you using dpy

#

dpy is not for beginners

#

you should learn more python before using discord.py

#

do you understand the concept of decorators

#

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

slate swan
#

I learned dpy first and I know lots of shit about dpy and not so much about py

#

and it's a bad feeling

#

so don't do that

#

no, kayle

boreal ravine
slate swan
#

the answer is no

boreal ravine
#

💀

slate swan
#

and the answer was actually no

hasty iron
#

wow speedrunning any%?

slate swan
#

lmao actually speedrunning knowledge

#

@bot.event is a decorator aswell

#

anything that starts with @ is a decorator

hasty iron
#

then can you give us an example of a decorator

#

no, actual code example

#

a folder

random sleet
#

dosent work.

Somone pls help.

hasty iron
#

a namespace

#

your question is kinda vague

lament mesa
hasty iron
random sleet
random sleet
hasty iron
#

defining an asynchronous function

hasty iron
#

ok

solemn grove
#
@bot.listen()
async def on_message(message):
  if not (message.author == bot.user) and ('hi' in message.content.lower()):
    await message.reply("Hello")

Why it isn't pinging the user?

slate swan
#

Pinging?

#

mention_author=True

slate swan
#

lemme check on google

sick birch
#

Never heard of a @ operator

slate swan
#

Because it's not an operator

#

As simple as that

sick birch
#

Thought so

slate swan
#

it's not there

solemn grove
boreal ravine
sick birch
#

Since you have an if that checks if the message is by the bot

hasty iron
#

!e ```
print(1 @ 2)

unkempt canyonBOT
#

@hasty iron :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | TypeError: unsupported operand type(s) for @: 'int' and 'int'
sick birch
#

Oh wait ignore that

boreal ravine
#

wow

hasty iron
#

it is an operator(?)

sick birch
#

Didn’t see the not

boreal ravine
#

@ not for ints?

hasty iron
sick birch
#

That’s a decorator not an operator

boreal ravine
#

!e print("e" @ "e")

unkempt canyonBOT
#

@boreal ravine :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | TypeError: unsupported operand type(s) for @: 'str' and 'str'
hasty iron
#

i just wanted to test it

solemn grove
sick birch
#

Operators are == != etc

slate swan
#

it doesn't show on thingy

sick birch
slate swan
#

w3schools

#

if it's not on w3schools, it doesn't exist for me

boreal ravine
#

hm

slate swan
#

but I just learned about some stupid shit

sick birch
#

I was under the impression w3schools was a bad resource

slate swan
#

why

boreal ravine
#

it just doesnt have a "detailed" explanation on everything

sick birch
#

For learning new things it’s a bad resource

#

For quick reference yeah

boreal ravine
#

yes

slate swan
#

just like the dpy docs

boreal ravine
#

realpython is useful for me

hasty iron
slate swan
#

I'm really worried about it now

sick birch
hasty iron
slate swan
#

it's gonna ruin my day once

boreal ravine
hasty iron
#

they are just an API reference

sick birch
#

The dpy docs serve both as quick reference and in depth information

slate swan
sick birch
#

Personally I have trouble finding any good resources other than the GitHub and the reference

slate swan
#

well you don't really need more than github, stackoverflow and the docs

sick birch
#

Stack overflow is meh everything there is outdated for dpy from my experience

boreal ravine
#

SO is so outdated

sick birch
#

No

slate swan
#

no

hasty iron
#

if they were the same why would they both exist

slate swan
#

No

sick birch
#

Events are for events, commands are for commands

slate swan
#

^

#

bot.command() is called whenever a message starts with your prefix and continues with the function name

hasty iron
#

function name?

slate swan
#

or the name kwarg

hasty iron
#

bot.command is not the thing that’s called everytime a message is sent or whatever, it’s the callback of the command

slate swan
#

¯\_(ツ)_/¯

#

nop

#

symbols in a command I find cursed

boreal ravine
unkempt canyonBOT
boreal ravine
#

hm

hasty iron
sick birch
#

it does nothing

slate swan
#

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

boreal ravine
#

u did pass

sick birch
#

placeholder

boreal ravine
#

its an example..

sick birch
#

it indicates you should put something there by yourself

untold moon
#

can someone fix my bot pls

sick birch
#

no

boreal ravine
#

sure

slate swan
#

bot = bot.Commands (Commands_prefix ="-" this is entirely wrong

sick birch
#

pretty sure this channel is for asking for help

slate swan
#

what is that

untold moon
#

i need help fixing my bot who can help me it has collab

slate swan
boreal ravine
slate swan
#

thanks for correcting me, I had trouble with this for 2 hours man

#

command_prefix

#

thank you Tsekis

boreal ravine
#

/sarcasm

#

@slate swan cool badge sir

slate swan
gloomy quest
#

so i made this bot and

#

on repl

#

is it safe to leave the tokens around like that?

slate swan
#

nope

gloomy quest
#

or should i move my code to visual studio code

slate swan
#

use env , a tab named secrets in replit

slate swan
gloomy quest
#

thx

#

you're the best

untold moon
#

hi

#

can someone help me with this

reef shell
untold moon
reef shell
sick birch
#

also don't use replit

reef shell
#

and It's bot.run

#

Not Bot.run

untold moon
#

can someone help me it has collab i dont understandddd

#

e my friend coded it not me 😭

#

im trying to learn python but its hard

reef shell
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.

untold moon
untold moon
sick birch
#

you can't always have others fixing things for you you gotta try to fix it yourself

untold moon
#

i tryed thou

untold moon
#

but i make it worse E

sick birch
#

that's why we're here

untold moon
sick birch
#

plenty of people here to help out

untold moon
#

i did but i made it worse

umbral carbon
#

Object of type Member is not JSON serializable

#

a solution to this?

reef shell
sick birch
#

i.e a name, ID, something like that

#

afaik the json library allows you to serialize your own objects by subclassing it, don't remember 100% so you'll have to read into it

untold moon
sick birch
untold moon
reef shell
#

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

reef shell
#

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

untold moon
#

import discord
from discord.ext import commands
import os

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

@bot.event # the bot event decorator
async def on_ready():
print(f"{bot.user} is online")

@bot.command() # bot command decorator
async def ip(ctx: commands.Context):
await ctx.send("ult8.falix.gg:39318")

@bot.command() # bot command decorator
async def UltraFact(ctx: commands.Context):
await ctx.send("Ultra was helped by an awsome dude named AceyGoBoom to make this amazing bot")

@bot.event
async def on_message(message):
if message.content.startswith("hi"):
await message.channel.send("hello")

elif message.content.startswith("water"):
await message.channel.send("is drinkable 😏")

await bot.process_commands(message)

@bot.command()
async def avatar(ctx, member: discord.Member):
embed = discord.Embed(colour = discord.Colour.blue())
embed.set_image(url = member.avatar_url_as(format = "png"))
await ctx.send(embed = embed)

@bot.command()
@command.has_permissions(administrator=True)
async def ban():

await ctx.guild.ban(member)
await ctx.send(f'User {member} has been banned')

@bot.command()
@command.has_permissions(administrator=True)
async def kick():

bot.run(os.environ['Token'])

boreal ravine
#

@untold moon error?

untold moon
reef shell
#

@untold moon again saying, you need to learn python first.

boreal ravine
#

is empty

untold moon
boreal ravine
#

"line 46"

reef shell
#

You will not understand 90% of what we may say unless you learn basic python

boreal ravine
#

lmao

untold moon
#

E

gloomy quest
#

lol ok im moving my code to vs

#

repl sucks

sick birch
#

^

reef shell
#

Good decision

slate swan
#

Hello, could someone give me the code to write so that a bot can delete a certain number of messages from a command because i can't?

#

no

slate swan
#

tell us the part that doesn't go well

sick birch
#

what's stopping you from figuring out how to do it on your own

slate swan
# slate swan tell us the part that doesn't go well

I wrote this (with the token at the end) but nothing happens ... I also tried something else which also doesn't work :/

from discord.ext import commands

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

@bot.event
async def on_ready():
    print("The bot is ready!")

@bot.command()
async def clear(ctx, amount=5):
    await ctx.channel.purge(limit=amount)