#discord-bots

1 messages · Page 863 of 1

sick birch
#

This is pretty heavy on OOP with classes, inheritance, and what not but you had very little trouble getting it going on your own 😄

slate swan
#

multiple inheritance 😳

final iron
#

Hey Robin, wondering if you can do me a favor. Could you ask a mod to check if someone has been permanently banned or temp banned because if they were permanently banned I have proof that they're ban evading?

#

Or should I just make the report and see?

sick birch
#

Yeah I could relay that to them

#

Though probably contact modmail

wicked atlas
#

you could search their user id in message search

final iron
#

There are channels we can't see

#

Mods handle things "internally" all the time

wicked atlas
#

yeah, but if they were banned they probably got banned by a command

final iron
#

Why does that matter?

#

Mods can ban them internally with a command too

sick birch
#

@final iron I've let em know but regardless send @novel apex a message and they'll help you sort things out

final iron
#

Alright

#

Thanks for helping

sick birch
#

He says to the helper 😂

slate swan
wicked atlas
slate swan
boreal ravine
slate swan
#

@sick birch what's the right kwarg to edit the channel news

boreal ravine
unkempt canyonBOT
#

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

Edits the channel.

You must have the [`manage_channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to use this.

Changed in version 1.3: The `overwrites` keyword-only parameter was added.

Changed in version 1.4: The `type` keyword-only parameter was added.

Changed in version 2.0: Edits are no longer in-place, the newly edited channel is returned instead.
boreal ravine
#

Click the link to see

slate swan
sick birch
#

type=ChannelType.news?

boreal ravine
slate swan
#

you guys are funny

slate swan
#

shit won't work lol

boreal ravine
unkempt canyonBOT
slate swan
boreal ravine
#

yes

slate swan
#

ah alr

boreal ravine
#

why is the message cooldown so long here

slate swan
#

idk

#

its big now for some reason

boreal ravine
#

they keep raising and lowering it

slate swan
#

yeah

#

bro what 😂

#

bro

boreal ravine
slate swan
#

WAIT

#

you dont copy anything like that

#

TYPE MY BAD LOL

#

have you read docs?pithink

slate swan
#

is 6 am im slow lol

#

lol

#

but how can i set it to True/false

#

does it take bool?

boreal ravine
slate swan
#

Like if the before is false and after is true ban the member and set it back to false

#

or if before is true and after is false ban the member and set it back to true

final iron
#

Aight I sent in the report

slate swan
#

@slate swan

#

?

alpine furnace
#

Huh? That sentence was extremely unclear @slate swan please use commas

final iron
#

Commas are so useful tbh

vast gale
#

quick question:

#

env file:

  • BOT_TOKEN=...
  • TOKEN=...
#

which name is better

boreal ravine
#

prefer JSON tbh

silent ermine
#

I prefer bot_token incase I need other tokens and I need to find them

boreal ravine
vast gale
#

thanks you've influnced a pr

maiden fable
#

@slate swan what a name 👀

slate swan
maiden fable
#

Mind changing your nick?

vast gale
#

actually pfp is nsfw

maiden fable
#

Meh as if someone gonna change the PFP

vast gale
#

yeah but tos

#

sent a modmail

slate swan
maiden fable
#

Bruh why y'all talking about ToS all of a sudden

maiden fable
slate swan
#

lol

maiden fable
#

I can just direct them there and ping the mods ¯_(ツ)_/¯

#

Rip that was removed

#

!d discord.TextChannel.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
#

wont work

maiden fable
#

There smh

maiden fable
slate swan
#

no, wrong ping

maiden fable
#

U didn't ping anyone tho 👀

#

@slate swan just use that

slate swan
#

yeahhhhh, it didn't ping

vast gale
maiden fable
#

arl do be lurking here 👀

#

Smh u also started uwuing I'm out

vast gale
#

owo

#

so i'm trying to redo some examples 👀

maiden fable
#

Robin, why u lurking here?

vast gale
#

thinking of the best way to remove references to tokens

maiden fable
#

if channel.permissions_for(guild.me).send_messages:

maiden fable
sick birch
#

Very tempting

slate swan
#

**Your BOT is also a MEMBER ** blobthumbsup

maiden fable
maiden fable
slate swan
unkempt canyonBOT
#

@slate swan Please don't try to ping @everyone or @here. Your message has been removed. If you believe this was a mistake, please let staff know!

sick birch
slate swan
vast gale
maiden fable
maiden fable
vast gale
#

I mean, that's one way

#

but idk if a seperate file for the examples is the best strat

slate swan
#

sir robin awww

vast gale
#

strategy

sick birch
#

No what do you mean by "seperate file for the examples"

vast gale
#

oh

maiden fable
slate swan
maiden fable
vast gale
maiden fable
vast gale
#

rn i'm thinking of the best way to remove references to putting tokens directly in bot code

unkempt canyonBOT
#

examples/basic_bot.py line 79

bot.run("token")```
slate swan
#

auth_token maybe

#

but idk in the dev portal they show it as just token

maiden fable
sick birch
maiden fable
maiden fable
slate swan
maiden fable
#

Auth token

slate swan
#

?

vast gale
sick birch
#

Yeah the way I've always done it is how it's done in sir-robin

maiden fable
#

Nvm

unkempt canyonBOT
#

bot/constants.py line 14

token = environ.get("BOT_TOKEN")```
slate swan
#

who uses the get method-

boreal ravine
#

ikr

slate swan
#

"When you can't be with them, oppose them"

#

!src e

unkempt canyonBOT
#
Command: eval

Run Python code and get the results.

Source Code
slate swan
#

hope it helps you a bit

boreal ravine
#

!pypi jishaku

unkempt canyonBOT
slate swan
#

if youre using disnake use this

#

!pypi disnake-jishaku

unkempt canyonBOT
slate swan
#

well you can use the original afaik

#

i dont think tho

vast gale
#

inb4 everyone suggests a different lib

final iron
#

Don't use pycord

slate swan
#

😭

sick birch
slate swan
#

arl called it😔

final iron
#

Save yourself a lot of trouble and use disnake

vast gale
vast gale
sick birch
#

nah i use discord.py and implement the features myself

final iron
#

One of the worst forks

sage otter
#

Imagine using edpy

sick birch
final iron
vast gale
#

I use disnake and implement the features for everyone mmlol

#

and fast too

final iron
#

arl you say why pycord is bad

#

🗿

sick birch
#

if they wanna use it I think we should let them

#

Just make them aware of the flaws

final iron
#

We should make a strict disnake only policy 🗿

sick birch
#

Inform instead of persuade

sage otter
#

I swear man. People shill disnake like it’s Jesus or something.

final iron
#

Disnake is better than jesus

sage otter
#

in reality it’s just like every other fork

final iron
#

🗿

vast gale
slate swan
#

all dpy forks are bad

#

just use hikari lol

final iron
#

Has rin been pushed to pypi?

slate swan
maiden fable
#

py-cord*

final iron
#

!pypi rin

unkempt canyonBOT
sage otter
#

Because when it’s in production the user isn’t supposed to care about broken code.

maiden fable
#

!pypi py-cord

unkempt canyonBOT
vast gale
#

!pypi pycord

unkempt canyonBOT
maiden fable
#

Lol

vast gale
#

that's an ffmpeg wrapper lol

maiden fable
#

Yea

vast gale
#

@sick birch so do you actually still use raw dpy or was that a joke...?

sage otter
#

fairly sure he uses disnake

final iron
#

Robin seems like the person to implement the disnake features himself

sick birch
#

But I don't do bot dev that much anymore

slate swan
#

no

sick birch
#

I recently implemented modals myself using d.js if that counts

slate swan
#

robin is a chad he uses d.jspithink

sick birch
#

i used it like twice

#

nah they're still active development

#

Honestly slash commands aren't that hard to listen to using discord.py

slate swan
#

why decos?

sick birch
#

The data's a bit messy/raw but you can clean that up yourself if you want

sage otter
#

Bro Robin what is this

sick birch
#

Before you say anything that wasn't me

sage otter
#

You have a whole cog dedicated to one command.

slate swan
#

👁️ 👁️

sick birch
#

why not ¯_(ツ)_/¯

sage otter
#

And you manually log inside the command

slate swan
#

🗿

sick birch
#

We'll probably add some other core features in there

#

and rename the cog and file

vast gale
#

imagine not having a standard logger/eval/ping/meta/etc commands smh

orchid linden
#

how can i make it so it's like

if member has muted role:
 remove all roles except muted role```
sage otter
#
if role in member.roles:
    await member.remove_roles([i for i in member.roles if i != role])
   
``` assuming role is the muted role
#

Filter out the mute role from the list so you don’t remove that obviously

#

You can do that list comp

maiden fable
sick birch
sage otter
#

Oh crazy

maiden fable
#

Better than doing API calls repeatedly lol

sage otter
#

My bad then

maiden fable
#

That's why it's named remove_roles

sage otter
#

First time boys. I’m new here.

sick birch
#

Nah it's good

maiden fable
#

Yea yea

sick birch
#

oops

vast gale
sick birch
#

too much javascript 🙁

frozen elk
#

i want the whole message but this only picks the first word of the meg

jade garden
#
Traceback (most recent call last):
  File "/home/runner/Proton-7/venv/lib/python3.8/site-packages/jishaku/features/python.py", line 145, in jsk_python
    async for send, result in AsyncSender(executor):
  File "/home/runner/Proton-7/venv/lib/python3.8/site-packages/jishaku/functools.py", line 109, in _internal
    value = await base.asend(self.send_value)
  File "/home/runner/Proton-7/venv/lib/python3.8/site-packages/jishaku/repl/compilation.py", line 143, in traverse
    yield await func(*self.args)
  File "<repl>", line 3, in _repl_coroutine
    role = discord.utils_get(ctx.guild.roles, name="quarantine")
AttributeError: module 'discord' has no attribute 'utils_get'
vast gale
#

utils.get

frozen elk
#

yeah i got it tysm

jade garden
heavy folio
jade garden
sick birch
#

id is an int not a string

#

Are you trying to import the base exception?

half flower
#

hello I am running a discord bot on repl.it with a flask server and uptime robot pinging it, i have done this with another bot in the past and that bot has been running for months, but this new bot I made goes down every hour and I keep getting this in the console(I'm assuming from every ping i get from uptimerobot):
[27/Feb/2022 04:39:00] "GET / HTTP/1.1" 200 -
Any ideas as to why this is happening?

sick birch
#

perhaps from discord import DiscordException?

sick birch
half flower
#

The bot doesn't run 24/7 it goes offline

sick birch
#

That's replit for ya

half flower
#

unlike my other repl.it bot that has been running for months and still is

sick birch
#

Heavily recommend you switch off replit and find an actual host

#

yeah that's not right

vast gale
#

yeah, pycord screwed that up

wary zenith
#

im trying to use motor, and im wonder if this code would work for motor or if something is missing? ```py
motor.motor_asyncio.MotorClient(key)

async def open_account(user: discord.Member):
try:
post = {"_id": str(user.id), "Balance": 0}
await cluster.Botswag.Accounts.insert_one(post)
except:
pass

@client.command(aliases=["bal"])
async def balance(ctx):
await open_account(ctx.author)
embed = discord.Embed(title=f"{ctx.author.name.title()}'s Balance",
description=await cluster.Botswag.Accounts.find_one({"_id": str(ctx.author.id)})['Balance'],
color=discord.Color.green())
await ctx.send(embed=embed)```

vast gale
#

its shadowed and importing discord.errors imports discord.commands.errors

wary zenith
#

discord.commands.errors should work

wary zenith
maiden fable
#

@languid wagon u installed py-cord?

#

There u go

#

It uses the discord namespace

#

So there are these folders made for each module

#

disnake modules makes a folder named disnake

#

But py-cord uses the discord folder only

#

So that can result in errors if u had discord.py installed

#

Uninstall dpy, py-cord then reinstall py-cord

#

Weird... try doing pip show py-cord

final iron
#

Just use disnake 🗿

maiden fable
#

Hmmmm and what's the error?

#

Ah

#

!d disnake.Permissions.moderate_members

unkempt canyonBOT
maiden fable
#

They haven't implemented it

vast gale
#

I wonder if its one of their broken pushes mmulu

wary zenith
#

@slate swan i used motor and im still getting this result

slate swan
maiden fable
#

U do know Python is easier, right? 👀

wary zenith
#
motor.motor_asyncio.MotorClient(key)

async def open_account(user: discord.Member):
    try:
        post = {"_id": str(user.id), "Balance": 0}
        await cluster.Botswag.Accounts.insert_one(post)
    except:
        pass


@client.command(aliases=["bal"])
async def balance(ctx):
    await open_account(ctx.author)
    embed = discord.Embed(title=f"{ctx.author.name.title()}'s Balance",
                          description=await cluster.Botswag.Accounts.find_one({"_id": str(ctx.author.id)})['Balance'],
                          color=discord.Color.green())
    await ctx.send(embed=embed)
maiden fable
#

What's the issue?

wary zenith
maiden fable
#

Not a code issue, it's an internet issue

maiden fable
#

Host the same code on a VPS and u gonna get about a 100 MS ping more or less, depending on the region the VPS is hosted in

maiden fable
#

Yea they do

wary zenith
#

oof

#

guess im gonna have to lag then 😂

maiden fable
#

Hahaha well there are free services too, but they suck

wary zenith
#

one of my friends has a vps, ill see if i can ask for access or smth

maiden fable
#

Well, it will be easier if he installs pterodactyl panel/puffer panel on it

wary zenith
#

ic

maiden fable
#

Smh typos go brrr

halcyon onyx
#

hello

#

heeeeeeeeeelpppppp!

maiden fable
maiden fable
spring flax
#

let me shoe what i get

halcyon onyx
#

how i do multiple commands at the same time

maiden fable
spring flax
sick birch
#

VPSs usually let you pick the region where it's hosted, so you can get really good ping, like < 10 if you tried

halcyon onyx
#

when the bot in this loop everything stop working

spring flax
#

constant at around 500

maiden fable
# spring flax

Hmm, I don't really know... What's the region of yr VPS?

spring flax
#

let me check

sick birch
maiden fable
#

Yea use asyncio.sleep

spring flax
halcyon onyx
maiden fable
maiden fable
spring flax
#

wait wth

sick birch
spring flax
#

let me check my ping command

maiden fable
maiden fable
#

What about yr hood which is with me-

wary zenith
#

why would you do that

maiden fable
sick birch
#

it's kind of like import disnake as discord

maiden fable
#

=D

sick birch
#

that's like a wolf dressed as a sheep

maiden fable
#

Wait, I know THE BEST: import hikari as nextcord

#

Ezzz

sick birch
#

very scary

maiden fable
#

Imagine

#

@sick birch let's just use raw aiohttp module instead of all this wrapper shit, what say?

sick birch
#

that's what i've been doing lmao

spring flax
# maiden fable That's 200 MS

this is my ping command

@bot.command(brief=['Ping', None, 'Displays the bot ping', '=ping', None])
@trial_moderator_only()
async def ping(ctx):
    start = time.time()
    message = await ctx.send("Ping!")
    end = time.time()
    duration = (end - start) * 1000
    await message.edit(content='Pong! `{:.2f}` ms'.format(duration))
maiden fable
wary zenith
maiden fable
halcyon onyx
#

hello

wary zenith
#

hello

sick birch
#

hello

halcyon onyx
#

i tried it doesnt work

vast gale
#

oh no

wary zenith
#

what

maiden fable
#

What

vast gale
#

i regret everything

maiden fable
#

I regret joining discord

sick birch
#

why is that so?

vast gale
#

brb deleting github

wary zenith
#

💀

halcyon onyx
#

i have 2 def ok and i want the bot do the 2 tasks

maiden fable
halcyon onyx
#

at the same time

wary zenith
vast gale
maiden fable
#

Meh, I can't get off it since I got better friends in here than irl

maiden fable
#

Don't tell me it's hikari 👀

wary zenith
#

anyone seen random library questionable variable names?

maiden fable
#

?

halcyon onyx
#

@client.command()
#Getting the input from the user on discord text chat
async def set_timer(ctx, arg):
am = discord.AllowedMentions(
users=True
)
arg = str(arg)
await ctx.send(f"timer set to {arg}")
#This to get your real time
while True:
now = datetime.now()
final = now.strftime('%I:%M') #12-Hour Format
#Final = now.strftime(%H:%M') #24-hour format
asyncio.sleep(1)
if final == arg:
await ctx.send(ctx.author.mention, allowed_mentions=am)
break

#

the code is working fine

maiden fable
#

!code thanks

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.

vast gale
halcyon onyx
#

but the bot stuck on the loop till it finish

wary zenith
#

skull

maiden fable
spring flax
# maiden fable Why...

yeah idk i haven't paid much attention to that not sure what i even had as my command but what's so bad about this? i did change to bot latency but still want to know

maiden fable
#

If u don't take it the other way

wary zenith
#

ic

maiden fable
#

It's used as an alternative for and in English (at least for me)

maiden fable
sick birch
#

.latency is the time between HEARTBEAT and HEARTBEAT_ACK which accurately says the latency time of the websocket

maiden fable
#

Yea

sick birch
#

timing a await ctx.send() includes overhead

wary zenith
maiden fable
#

Idk

#

I don't do bot deving anymore

wary zenith
#

lol

maiden fable
#

Not until voice receive becomes a thing in disnake (arl 👀)

vast gale
#

but also yes, they aren't a fork

maiden fable
#

@sick birch voice receive implement when in your custom wrapper?

sick birch
#

man i haven't even looked at that part of it yet

maiden fable
wary zenith
maiden fable
#

Best of luck scrolling through discord.js's source

wary zenith
boreal ravine
slate swan
sick birch
wary zenith
boreal ravine
unkempt canyonBOT
#

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

New in version 2.0.
wary zenith
#

i dont see any documentation for it anywhere

maiden fable
boreal ravine
maiden fable
#

Yea

wary zenith
maiden fable
#

Just run this in yr command prompt (:

tacit storm
sick birch
#

questionable naming practices but that's okay

slate swan
#

useletters so you would save some bytes🗿

wary zenith
sick birch
#

come on it's not 1995 where we use floppy drives that have 14 megabytes of storage

wary zenith
#

the fact that thats just 23 yrs ago 💀

#

unless terrible math

sick birch
#

slightly off

wary zenith
#

prolly 27

sick birch
#

my point is i don't think it's worth sacrificing readbility for that little bit of saved storage

slate swan
sick birch
#

but if you wanted to nothing stopping you

wary zenith
#

!e py print(1995 + 27)

unkempt canyonBOT
#

@wary zenith :white_check_mark: Your eval job has completed with return code 0.

2022
wary zenith
#

ahhh

slate swan
#

this man really needed to do the math in python😭

wary zenith
#

its 12:46 ok 😭

slate swan
#

1am here lol

wary zenith
boreal ravine
#

!ot stop going off topic

unkempt canyonBOT
slate swan
#

ok

wary zenith
#

ok

sick birch
#

ok

halcyon onyx
#

hello

slate swan
#

hello

halcyon onyx
#

heeeeeeeellllllllllllllp!!!!!!!!!!!!!!!!!!!

slate swan
#

with?

halcyon onyx
#

see i have 2 def ok and i want to run them at the same time

slate swan
#

you have 2 methods?

#

you would just call a method inside of the method

halcyon onyx
#

#Mention Bot:

@client.command()
async def set_timer(ctx, arg):
am = discord.AllowedMentions(
users=True
)
arg = str(arg)
await ctx.send(f"timer set to {arg}")
while True:
now = datetime.now()
final = now.strftime('%I:%M') #12-Hour Format
#Final = now.strftime(%H:%M') #24-hour format
asyncio.sleep(1)
if final == arg:
await ctx.send(ctx.author.mention, allowed_mentions=am)
break

#

see

#

the bot stuck on while loop

#

when the bot doing this while true everything stop working

slate swan
#

you should use a loop for a timer lol

boreal ravine
halcyon onyx
boreal ravine
#

Why are you even using a while loop?

halcyon onyx
#

it's working fine

boreal ravine
halcyon onyx
halcyon onyx
slate swan
#

use a db and store the time and just check the time each minute

#

if you want to make a timer

halcyon onyx
#

if the timer is work everything in the bot stop working till the bot finish

slate swan
#

use my method

halcyon onyx
#

ill try

halcyon onyx
slate swan
halcyon onyx
#

like i have to split the code in 2 def right?

slate swan
#

in 2 methods? i doubt it

halcyon onyx
#

i dident sleep two days to fix that

#

i cant even type

slate swan
#

¯\_(ツ)_/¯

hushed galleon
halcyon onyx
#

i think no one understand the issue

maiden fable
#

👀

#

@halcyon onyx what's the issue?

slim ibex
#

And what @hushed galleon said, await your asyncio.sleep

halcyon onyx
hushed galleon
#

besides the missing await, their infinite loop is mostly alright

maiden fable
halcyon onyx
#

ofc

hushed galleon
#

we replied to their code twice

maiden fable
#

It's fine, lemme see

unkempt canyonBOT
#

Hey @halcyon onyx! 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!

wary zenith
#

skull

halcyon onyx
#

😂😂😂😂

maiden fable
#

?

halcyon onyx
#

token = "--"

@client.event
#Message send with bot startup
async def on_ready():
print('We have logged in as {0.user}'.format(client))

#Mention Bot:

@client.command()
async def set_timer(ctx, arg):
am = discord.AllowedMentions(
users=True
)
arg = str(arg)
await ctx.send(f"timer set to {arg}")
while True:
now = datetime.now()
final = now.strftime('%I:%M') #12-Hour Format
#Final = now.strftime(%H:%M') #24-hour format
sleep(1)
if final == arg:
await ctx.send(ctx.author.mention, allowed_mentions=am)
break

#Ban / Kick / UnBan:

@client.command()
@commands.has_permissions(administrator=True)

#Kick
async def kick(ctx, member : discord.Member, *, reason = None):
if ctx.message.author != member:
await member.kick(reason = reason)
await ctx.send (f"User {member} got Kicked")

@client.command()
@commands.has_permissions(administrator=True)

#Ban
async def ban(ctx, member : discord.Member, *, reason = None):
if ctx.message.author != member:
await member.ban(reason = reason)
await ctx.send (f"User {member} got Banned")

@client.command()
@commands.has_permissions(administrator=True)

#UnBan
async def unban(ctx, *, member):
if ctx.message.author != member:
banned_users = await ctx.guild.bans()
member_name, member_discriminator = member.split('#')

for ban_entry in banned_users:
    user = ban_entry.user

    if (user.name, user.discriminator) == (member_name, member_discriminator):
        await ctx.guild.unban(user)
        await ctx.send(f"User {user.name}#{user.discriminator} got Unbanned")

#clear
@client.command()
@commands.has_permissions(administrator=True)

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

#add and delete channels

client.run(token)

wary zenith
#

bro go refresh ur token 💀

hushed galleon
#

please just await the asyncio.sleep

halcyon onyx
slate swan
#

💀 the unban command...

maiden fable
#

I smell Lucas

halcyon onyx
maiden fable
slate swan
#

f strings and format😔

halcyon onyx
#

give me it

slim ibex
#

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

wary zenith
maiden fable
#

Ezzz

slate swan
slate swan
maiden fable
slate swan
halcyon onyx
#

but there is hope to fix main issue 😥😥

slate swan
#

What's the issue tho

maiden fable
#

Qulx be like: Read the message history dude. I'm tired of explaining repeatedly ffs

halcyon onyx
#

when the bot on the loop everything stop working

slate swan
#

instead of looping every second

halcyon onyx
#

im done

maiden fable
#

Uhhh, just use tasks?

slate swan
#

and make sure the arg is an integer

halcyon onyx
slate swan
wary zenith
slate swan
#

Or cache atleast

maiden fable
#

Meh, my brain isn't working rn anyways so ig ignore me lmao

slate swan
#

Okimii's smart

wary zenith
#

can you do an async lambda?

slate swan
#

you can cache it with a dict but if the bot restarts bye bye timer

wary zenith
halcyon onyx
#

my search history explain it?

slate swan
#

you dont want to see my history😳

wary zenith
slate swan
#

my history~

#

yall down bad

wary zenith
#

nah

slate swan
#

🗿

halcyon onyx
wary zenith
#

my history is ok i think

maiden fable
#

Lmao same

slate swan
#

Ok this sucks

#

The last thing I searched for was pycord docs

#

😶‍🌫️

wary zenith
#

kinda off topic but here it is

maiden fable
#

Hmm, if u open my brave browser... u'll see ||godot||'s website

slate swan
wary zenith
halcyon onyx
#

bro just use ctrl + shift + n

slate swan
#

\emoji

#

\🗿

halcyon onyx
#

win + . for emojis for windows

slate swan
#

🗿

#

linux noises

wary zenith
#

uhhhhhhhhhhhhhhh

maiden fable
#

\🗿

slate swan
#

I have gnome characters application tho

halcyon onyx
#

win + v to see all copy history

wary zenith
#

:moyai

slate swan
#

moyai😔

wary zenith
#

\🗿

halcyon onyx
#

think that useful

slate swan
#

Love how this channel talks about everything other then discord bots.

halcyon onyx
#

😂😂🤣🤣

maiden fable
#

I mean this is the most active topical channel

wary zenith
slate swan
#

Agreed

wary zenith
slate swan
#

🎩
🗿
👔

halcyon onyx
#

i think english is easy

slate swan
slate swan
slate swan
wary zenith
slate swan
maiden fable
halcyon onyx
#

do any one here learned arabic?

maiden fable
#

!ot

unkempt canyonBOT
slate swan
#

the channel name🐒

slate swan
wary zenith
#

what are these channel names

slate swan
#

They are off topic channels and the name changes after some.time

slate swan
slate swan
#

every 24h

#

okimii knows his maths pogchamp

#

Ping me if y'all shift to some ot channel

halcyon onyx
#

do u know on arabic the table is female and the chair is male 😂😂

slate swan
#

and he's gonna run the ot command now

slate swan
slate swan
slate swan
slate swan
#

I love you guys🫀

#

!ot before I drop bugs in akeno here

unkempt canyonBOT
slate swan
unkempt canyonBOT
#

7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.

slate swan
slate swan
wary zenith
maiden fable
halcyon onyx
slate swan
wary zenith
slate swan
#

Ohhh

halcyon onyx
#

there is any anime like boku no hero?

slate swan
#

good to see this channel in its original state peephappy

#

Meh pokeapi doesn't have a ratelimit so I don't need to care about that , gotta make it optional

wary zenith
#

lmao

sick birch
slate swan
maiden fable
wary zenith
#

anime in discord bots 💀

slate swan
sick birch
halcyon onyx
#

its 9:30 am 😂😂

slate swan
#

Well that makes sense since it's a RESTapi

slate swan
slate swan
#

imagine requesting requesters to not request too much to not overload the server sadcat

wary zenith
sick birch
#

say request one more time

halcyon onyx
#

on middle east its soo cold 95f, how u live on USA

slate swan
#

💀

slate swan
slate swan
slate swan
#

just the Pokemon database

sick birch
slate swan
#

lol

sick birch
#

tooling for databases and APIs are rich in javascript so many people do do that

wary zenith
#

bro is there a js server

slate swan
#

bestthisiisfine javascript is the best

slate swan
wary zenith
#

so i can bother them about making a discord bot in ts

slate swan
#

🗿

wary zenith
#

ive been trying to do for hrs

wary zenith
slate swan
slate swan
#

just learn ruby🗿

#

No

maiden fable
#

!ot

unkempt canyonBOT
slate swan
#

glad to see the good old hunter catsip

wary zenith
slate swan
#

are you?

wary zenith
#

idk eno

slate swan
#

dont press it

#

Press never mind

slate swan
wary zenith
#

bot says nevermind 💀

maiden fable
#

Dudes can u take this talk to an OT channel?

slate swan
maiden fable
#

!rule 7 exists for a reason

unkempt canyonBOT
#

7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.

red sundial
#

you're really annoying lol

maiden fable
red sundial
#

well stay there

maiden fable
slate swan
#

you guys should go to sleep🗿

red sundial
#

no

wary zenith
slate swan
slate swan
slate swan
slate swan
unkempt canyonBOT
#

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

slate swan
#

What?

slate swan
#

🧠

#

no need for dpy

slate swan
#

dpy doesnt require that much brain tbh

slate swan
slate swan
slate swan
slate swan
slate swan
slate swan
slate swan
wary zenith
wary zenith
slate swan
slate swan
wary zenith
#

el risitas es muerte

slate swan
#

😔

maiden fable
unkempt canyonBOT
#

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

alpine furnace
#

Use English server emotes to the best of your ability

slate swan
#

🗿

alpine furnace
slate swan
#

😔

slate swan
stray carbon
#
@client.command()
@commands.has_role(848230687508922430)
async def test(ctx):
  await ctx.send('Done!')

How to make the bot send error message if user doesnt have role

wary zenith
maiden fable
#

!d discord.ext.commands.CheckFailure

unkempt canyonBOT
#

exception discord.ext.commands.CheckFailure(message=None, *args)```
Exception raised when the predicates in [`Command.checks`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command.checks "discord.ext.commands.Command.checks") have failed.

This inherits from [`CommandError`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandError "discord.ext.commands.CommandError")
maiden fable
#

Use this

wary zenith
#

failure*

#

my typing speed is negative since my wrist got sprained

slate swan
#

anyways, back to topic zucchydrated

maiden fable
#

Wasn't expected from u

compact eagle
#

yo i got a discord bot rn, and its got this at the end

await ctx.send(embed=e)
``` after an embed, can this somehow make it so it replies to the user initating the cmd
stray carbon
#
@client.command()
@commands.has_role(848230687508922430)
exception discord.ext.commands.CheckFailure(message="You must have \<@&848230687508922430> to use this command.", *args)
async def test(ctx):
  await ctx.send('Done!')
#

this?

compact eagle
#

how can i make it so the bot will reply to the user that initiated the command?

wary zenith
#

like this: py @test.error async def test_error(ctx, error): if isinstance(error, discord.ext.commands.CheckFailure): await ctx.reply("You must have \<@&848230687508922430> to use this command.")

compact eagle
stray carbon
#

oh

slate swan
#

Since CheckFailure means any kind of check failures

compact eagle
#
e = discord.Embed(title=f'**Profile Link**',url=f'https://roblox.com/users/{userid}',color=0x00ff80)
``` so i have that up here but wanna make it look like this, how can i do that?
pliant compass
#

Can I make my bot edit a message that someone sent?

compact eagle
boreal ravine
unkempt canyonBOT
#

add_field(*, name, value, inline=True)```
Adds a field to the embed object.

This function returns the class instance to allow for fluent-style chaining.
slate swan
slate swan
pliant compass
compact eagle
slate swan
stray carbon
slate swan
unkempt canyonBOT
#

@discord.ext.commands.has_permissions(**perms)```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member has all of the permissions necessary.

Note that this check operates on the current channel permissions, not the guild wide permissions.

The permissions passed in must be exactly like the properties shown under [`discord.Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions").

This check raises a special exception, [`MissingPermissions`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingPermissions "discord.ext.commands.MissingPermissions") that is inherited from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
stray carbon
#

oh

#

@discord.ext.commands.has_permissions(manage_server=true)?

slate swan
#

works

#

Capital T in true tho

#

And it's guild, not server

compact eagle
#

how can i refer to the person who sent the command in an embed ?

wary zenith
#

but you need commands.has_permissions decorator

vale wing
unkempt canyonBOT
#
class discord.ext.commands.Context(*, message, bot, view, args=..., kwargs=..., prefix=None, command=None, invoked_with=None, invoked_parents=..., invoked_subcommand=None, ...)```
Represents the context in which a command is being invoked under.

This class contains a lot of meta data to help you understand more about the invocation context. This class is not created manually and is instead passed around to commands as the first parameter.

This class implements the [`Messageable`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable "discord.abc.Messageable") ABC.
slate swan
stray carbon
#
@client.command()
async def test(ctx, error):
  if isinstance(error, discord.ext.commands.has_permissions(manage_guild=True)):
    await ctx.reply("You do not have permissions to use this command.")
compact eagle
vale wing
#

The what

compact eagle
#

e being the embed

vale wing
#

May I ask what's your py knowledge

compact eagle
#

not alot im just tryna make a simple bot

vale wing
#

Well I recommend to learn basics of python first

#

Like OOP

vale wing
stray carbon
#

idk

vale wing
#

What you tryna do anyways

#

Error handler or smth

maiden fable
#

Oh your nitro ended, sad

stray carbon
#

im trying make cmd which requires manage guild perms

boreal ravine
stray carbon
#
@client.command()
async def test(ctx, error):
  if isinstance(error, discord.ext.commands.has_permissions(manage_guild=True)):
    await ctx.reply("You do not have permissions to use this command.")
  else:
    await ctx.reply('done')
#

maybe like this?

vale wing
maiden fable
#

Wait what

stray carbon
#

raise MissingRequiredArgument(param)
discord.ext.commands.errors.MissingRequiredArgument: error is a required argument that is missing.

vale wing
stray carbon
#

how?

#

im confused :/

vale wing
#

!d discord.ext.commands.Bot.listen

unkempt canyonBOT
#

@listen(name=None)```
A decorator that registers another function as an external event listener. Basically this allows you to listen to multiple events from different places e.g. such as [`on_ready()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_ready "discord.on_ready")

The functions being listened to must be a [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine "(in Python v3.9)").

Example...
stray carbon
#

@bot.listen()
async def test(ctx, error):
if isinstance(error, discord.ext.commands.has_permissions(manage_guild=True)):

#

but how to set it req for cmd

#

😅

slate swan
#
@bot.command()
@bot.has_permission('ADMINISTRATOR')
async def ban(ctx, member : nextcord.Member, *, reason):
    await member.ban(reason=reason)
    embed = nextcord.Embed(title="Ban", description="mentioned user banned.")
    await ctx.send(embed=embed)```
maiden fable
#

No

#

has_permissions(administrator=True)

slate swan
#

Oh, thanks

stray carbon
maiden fable
#

Huh?

stray carbon
#

im confused

#

im trying to make command which requires manage_guild perms and sends a message if user doesnt have it

slate swan
stray carbon
#

yes i did

slate swan
#

Oh

compact eagle
#

getting the user of the person who sent the cmd rn,

author = commands.Context.author
    e.set_footer(text='Requested by ' + str({author}))
``` is what im using at the end of my embed and im getting this:

```txt
Requested by {<discord.utils.cached_property object at 0x0000019928A9FDC0>}
slate swan
stray carbon
#

is this code complete?

slate swan
#

Maybe that help xd

stray carbon
#

:/ ok

slate swan
#

U want make error handler, right?

slate swan
stray carbon
#
@bot.event
async def on_command_error(ctx, error):

    send_help = (commands.MissingRequiredArgument, commands.BadArgument, commands.TooManyArguments, commands.UserInputError)

    if isinstance(error, commands.CommandNotFound):  # fails silently
        pass

    elif isinstance(error, send_help):
        _help = await send_cmd_help(ctx)
        await ctx.send(embed=_help)

    elif isinstance(error, commands.CommandOnCooldown):
        await ctx.send(f'This command is on cooldown. Please wait {error.retry_after:.2f}s')

    elif isinstance(error, commands.MissingPermissions):
        await ctx.send('You do not have the permissions to use this command.')
    # If any other error occurs, prints to console.
    else:
        print(''.join(traceback.format_exception(type(error), error, error.__traceback__)))

Is this error handler??

maiden fable
#

Yea

#

Wait

stray carbon
#
@client.command(name='eval', hidden=True)
@commands.is_owner()
async def _eval(ctx, *, body):
    """Evaluates python code"""
    env = {
        'ctx': ctx,
        'channel': ctx.channel,
        'author': ctx.author,
        'guild': ctx.guild,
        'message': ctx.message,
        '_': client._last_result,
        'source': inspect.getsource,
        'session': client.session
    }

    env.update(globals())
    body = utils.cleanup_code(body)
    stdout = io.StringIO()
    err = out = None
    to_compile = f'async def func(): \n{textwrap.indent(body, "  ")}'
    try:
        exec(to_compile, env)
    except Exception as e:
        err = await ctx.send(f'```py\n{e.__class__.__name__}: {e}\n```')
        return await ctx.message.add_reaction('\u2049')
    func = env['func']
    try:
        with redirect_stdout(stdout):
            ret = await func()
    except Exception as e:
        value = stdout.getvalue()
        err = await ctx.send(f'```py\n{value}{traceback.format_exc()}\n```')
    else:
        value = stdout.getvalue()
        if ret is None:
            if value:
                try:
                    out = await ctx.send(f'```py\n{value}\n```')
                except:
                    paginated_text = utils.paginate(value)
                    for page in paginated_text:
                        if page == paginated_text[-1]:
                            out = await ctx.send(f'```py\n{page}\n```')
                            break
                        await ctx.send(f'```py\n{page}\n```')
        else:
            bot._last_result = ret
            try:
                out = await ctx.send(f'```py\n{value}{ret}\n```')
            except:
                paginated_text = utils.paginate(f"{value}{ret}")
                for page in paginated_text:
                    if page == paginated_text[-1]:
                        out = await ctx.send(f'```py\n{page}\n```')
                        break
                    await ctx.send(f'```py\n{page}\n```')
    if out:
        await ctx.message.add_reaction('\u2705')  # tick
    elif err:
        await ctx.message.add_reaction('\u2049')  # x
    else:
        await ctx.message.add_reaction('\u2705')

Got error raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Bot' object has no attribute '_last_result'

maiden fable
#

Don't copy R. Danny's eval plz

stray carbon
#

i found it from github

#

not R.Danny

maiden fable
#

Still, don't copy code

#

!d exec use this (:

unkempt canyonBOT
#

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

just this?

cosmic agate
#

hi guys
which is the best hosting service for bot?

maiden fable
maiden fable
cosmic agate
#

no free pls

alpine furnace
#

Your computer

#

Lol

cosmic agate
#

vscode is good but

#

my computer slow as heck

alpine furnace
#

Just run it in a new terminal

cosmic agate
#

what about heroku?

alpine furnace
#

Discord bots don’t need many resources

#

No that’s not good

cosmic agate
#

XD my computer is literally a celeron at 1.6 ghz and 2 gb ram

cosmic agate
alpine furnace
cosmic agate
#

but its online service

#

easy for me too

cosmic agate
alpine furnace
#

Not to mention you don’t even get a full month of free hours

cosmic agate
#

really?

alpine furnace
#

Yes

cosmic agate
#

hmm

alpine furnace
#

Why not just host it on your computer

cosmic agate
#

so any other

alpine furnace
#

Uses like 50mb ram

#

And 0.1% cpu

cosmic agate
#

vscode the app takes alot of resources

#

i checked

alpine furnace
sick birch
alpine furnace
#

Shift click in explorer + open powershell

#

Then you can type in python and it works

cosmic agate
#

i used to use epikhost but they stopped free service

cosmic agate
sick birch
cosmic agate
#

?

sick birch
#

vscode runs on electron.js which can be slow

cosmic agate
maiden fable
sick birch
#

all you need is a terminal to run python

alpine furnace
#

It’s literally the same thing as cmd

#

Except, you know, the powershell language

final shard
#

it runs till u close pc

#

?

sick birch
#

alacritty 💪

alpine furnace
#

But you only need to run python in it so it doesn’t make any difference. Might have to change your execution policy to activate your venv, but whatever

cosmic agate
alpine furnace
#

Everything is default

cosmic agate
#

actually ive heard that powershell is trash too

maiden fable
# cosmic agate why may i ask?

If someone gains access to yr bot, he will be able to run shell commands on yr command and powershell has admin access

final shard
#

What about Docker Containers?

cosmic agate
#

?

sick birch
sick birch
#

containerize your applications so you don't have to deal with window's garbage command prompt or powershell

maiden fable
sick birch
#
  • docker is always good to know
alpine furnace
#

You’re still going to be running docker run in powershell to actually start your bot

final shard
#

@cosmic agate maybe u should try docker

alpine furnace
#

Lol

cosmic agate
#

hmm

#

but my pc

sick birch
final shard
#

u can use other pc

cosmic agate
#

you know what, imma build a new pc

alpine furnace
#

It’s literally one command to start your bot @cosmic agate

sick birch
#

if you're just gonna run python file.py then sure

cosmic agate
#

ive been saving up so hopefully it will run on that

sick birch
#

you said you had 4gb of ram atm?

#

you should be fine if you're just running a bot then

cosmic agate
#

my friend gifted me a rx 550 but i dont know ill runn on that

alpine furnace
#

I’m running a discord bot in a docker container on a trash vps, thing takes 20mb ram according to docker stats

#

You’re fine

sick birch
#

including docker overhead?

cosmic agate
alpine furnace
#

Yep, if docker stats includes that

sick birch
#

wow

final shard
#

so i suppose you all are giving a positive review on docker

alpine furnace
#

It’s pretty cool actually

sick birch
final shard
#

I see

halcyon onyx
#

hey

sick birch
#

docker is awesome

cosmic agate
alpine furnace
#

I have two other backend services and it communicates through grpc, though, so the bot just formats responses from those and doesn’t actually do much lifting itself

sick birch
#

Ah, bot as a front end?

alpine furnace
#

Yeah, basically

#

Lol, it’s a good strategy

sick birch
#

Seperation of concerns we call it

halcyon onyx
#

i have a while true if the bot on the while loop everything stop working till the bot finish any fix?

alpine furnace
#

Yepp

sick birch
#

Backend heavy lifting on one thing, frontend prettying up on another

sick birch
#

you yield control back to the event loop

alpine furnace
#

Yep and I can just expose an api for analytics stuff or for users to view

compact eagle
#

get username of the person who initiated the command? im having trouble

alpine furnace
#

Might be a good graphql learning opportunity

halcyon onyx
sick birch
alpine furnace
halcyon onyx
#

@client.command()
async def set_timer(ctx, arg):
am = discord.AllowedMentions(
users=True
)
arg = str(arg)
await ctx.send(f"timer set to {arg}")
while True:
now = datetime.now()
final = now.strftime('%I:%M') #12-Hour Format
#Final = now.strftime(%H:%M') #24-hour format
sleep(1)
if final == arg:
await ctx.send(ctx.author.mention, allowed_mentions=am)
break

alpine furnace
#

Check your library’s docs

sick birch
#

sleep() is blocking

#

use await asyncio.sleep() instead

halcyon onyx
sick birch
#

yes but it's still blocking

alpine furnace
halcyon onyx
stray carbon
#
@client.event
async def on_command_error(ctx, error):

    send_help = (commands.MissingRequiredArgument, commands.BadArgument, commands.TooManyArguments, commands.UserInputError)

    if isinstance(error, commands.CommandNotFound):  # fails silently
        await ctx.send(f'{error}.')

    elif isinstance(error, send_help):
        _help = await send_cmd_help(ctx)
        await ctx.send(embed=_help)

    elif isinstance(error, commands.CommandOnCooldown):
        await ctx.send(f'This command is on cooldown. Please wait {error.retry_after:.2f}s.')

    elif isinstance(error, commands.MissingPermissions):
        await ctx.send('You do not have the permissions to use this command.')
    # If any other error occurs, prints to console.
    else:
         print(''.join(traceback.format_exception(type(error), error, error.__traceback__)))

NameError: name 'traceback' is not defined

halcyon onyx
sick birch
#

what's the main issue?

sick birch
#

the bot stopping everything until loop's done?

halcyon onyx
#

the bot can do one job only

halcyon onyx
sick birch
#

yes, because you're using sleep()

#

it holds up the event loop

halcyon onyx
#

i will remove it

sick birch
#

replace it with asyncio.sleep()

halcyon onyx
#

still

#

same thing

halcyon onyx
compact eagle
alpine furnace
#

However for your case you could do str(ctx.author)

compact eagle
#

ok lemme try rq

#

it returns

{<User id=580891703133732917 name='carterfr' discriminator='0001' bot=False>}
``` when i str it
alpine furnace
#

Is that in a set or something

alpine furnace
stray carbon
#

oh

compact eagle
halcyon onyx
#

@client.command()
async def set_timer(ctx, arg):
am = discord.AllowedMentions(
users=True
)
arg = str(arg)
await ctx.send(f"timer set to {arg}")
while True:
now = datetime.now()
final = now.strftime('%I:%M') #12-Hour Format
#Final = now.strftime(%H:%M') #24-hour format
if final == arg:
await ctx.send(ctx.author.mention, allowed_mentions=am)
break

there is something blocking where it's?

#

on while loop

alpine furnace
#

What are you printing exactly

compact eagle
sullen linden
#

im not sure how to diagnose my problem. im working with interactions in nextcord and mentions. Im printing out the mentions and its None even though the contents show it has some .. and it works fine in two other servers my bots in, just not a new third server

compact eagle
alpine furnace
#

Oh, that was it

#

It wasn’t a format string kekw

halcyon onyx
#

any one can help please?

quick gust
#

ask?

halcyon onyx
#

there is something blocking async

#

@client.command()
async def set_timer(ctx, arg):
am = discord.AllowedMentions(
users=True
)
arg = str(arg)
await ctx.send(f"timer set to {arg}")
while True:
now = datetime.now()
final = now.strftime('%I:%M') #12-Hour Format
#Final = now.strftime(%H:%M') #24-hour format
if final == arg:
await ctx.send(ctx.author.mention, allowed_mentions=am)
break

#

where

sullen linden
#

my guess is the "if final == arg:" is never set as true
there might be a better way to do that with tasks