#discord-bots

1 messages · Page 710 of 1

cloud dawn
slate swan
#

welp idk how i didnt knew that thats basic stuff

#

second question

cloud dawn
#

This is the Pypi packages, inside the root folder is the setup and additional information.

slate swan
#

yeah ik

#

i just didnt think about it for a reason

#
ctx.send()

ctx is the class and .send is just a function /attr right?

slate swan
#

yes

cedar stream
#

And send is a method yes

cloud dawn
#

!d discord.ext.commands.Context

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
#

withing the class right

cloud dawn
#

Context is just all the handy dandy variables inside one class.

cedar stream
slate swan
slate swan
#

final one
how would i change a var from a class with a subclass right?

cedar stream
#

Wdym

cloud dawn
#

You can also make your own custom context to include the database connection for example so you don't have to address that every time.

slate swan
cloud dawn
#

Lemme write an example 1 sec

brave vessel
#

You're waiting for the event but that only ever happens once

slate swan
#

discords domain isnt like that

proven osprey
brave vessel
#

hmm, I wonder if just a while loop would work

proven osprey
#

i tried

cloud dawn
unkempt canyonBOT
#

@cloud dawn :white_check_mark: Your eval job has completed with return code 0.

001 | 5
002 | 10
slate swan
brave vessel
#

you can use a View class and then do something like

import discord

class MyView(discord.ui.view):
  @discord.ui.button(label="Your button's label")
  async def [name of function goes here](self, button, interaction):
    await interaction.response.send_message("Hello, world!") # this responds with Hello, world! whenever the button is pressed

async def your command stuff goes here(...):
  await ctx.send(..., view=MyView())

that should work

cloud dawn
brave vessel
slate swan
brave vessel
#

oh wait

#

nvm

pliant gulch
#

That's a yikes!

#

This is why those libraries are poorly designed

slate swan
#

im making a dumb command because im bored but it says "command not found"

#

ill show code

#

ik its a dumb command

cedar stream
#

With ((

#

()

slate swan
#

ah thought i had that must've deleted it

slate swan
#

anyone wanna make a discord bot with me? im bored.

placid skiff
#

and is good with web dev

cloud dawn
#

But.. flask is sync ;-;

placid skiff
#

A bot dashboard doesn't need to be async lel

cloud dawn
#

It does lol

placid skiff
#

why lol?

cloud dawn
#

Because the bot is also async..??

#

You can't just mix those 2

placid skiff
#

I'll think a way then D_D

slate swan
cloud dawn
#

Most python bots that have a dashboard do IPC routing.

slate swan
#

my friend is good with web and hes helping me

placid skiff
cloud dawn
#

Not many people do that here. I've seen some but those people usually help others and are experienced coders.

cedar stream
cloud dawn
#

But then with the IPC routes it's still better performance wise to make it async.

cedar stream
#

In quarkus and react

cloud dawn
#

You can do it yeah but it will be slower depending on the user base.

#

Make the whole bot sync if it is just one guild.

#

idm lol

cedar stream
#

I meant the site

cloud dawn
cedar stream
#

Yes, that is reactive

#

But backend

#

U can use flask

cloud dawn
#

react is already async lol

#

flask is sync

cedar stream
#

Yes, react is reactive

#

Bit different than async

crude crater
pliant gulch
cloud dawn
cedar stream
#

Wdym

snow flare
#

in the on_member_join event, how can I see which invite the person used, or who invited him?

cloud dawn
#

!d discord.Invite

unkempt canyonBOT
#

class discord.Invite```
Represents a Discord [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild") or [`abc.GuildChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.GuildChannel "discord.abc.GuildChannel") invite.

Depending on the way this object was created, some of the attributes can have a value of `None`.

x == y Checks if two invites are equal.

x != y Checks if two invites are not equal.

hash(x) Returns the invite hash.

str(x) Returns the invite URL...
manic wing
#

nah

#

wrong shit, lemme check something

#

!d discord.Guild.invites || it is this

unkempt canyonBOT
#

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

Returns a list of all active instant invites from the guild.

You must have the [`manage_guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_guild "discord.Permissions.manage_guild") permission to get this information.
cloud dawn
#

I don't think you can see who invited who.

manic wing
#

actually

#

no

cloud dawn
#

No names.

#

You'd need to write some serious custom shit for that lmao

visual island
#

you can see which invite.uses changed

cloud dawn
manic wing
#

isnt everything ‘custom’? pithink

proven ore
#

hi, for some reason, my python doesnt recognize discord any more, tried reinstalling python, didnt work

cloud dawn
proven ore
cloud dawn
proven ore
#

..

tame sierra
#

real quick, how do I check if a user has a specifically named role before running a chunk of code?

cloud dawn
#

!d discord.Member.roles

unkempt canyonBOT
#

property roles: List[Role]```
A [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") that the member belongs to. Note that the first element of this list is always the default [‘@everyone](mailto:'%40everyone)’ role.

These roles are sorted by their position in the role hierarchy.
pliant gulch
cloud dawn
tame sierra
lapis lintel
cloud dawn
sonic gale
#

!deleteserver

#

no

lapis lintel
#

LMAO

cloud dawn
#

Bruh nice try though

sonic gale
#

ty

crude crater
manic wing
#

ignore wiser btw, he just goes around trolling xD

ionic wadi
#

my bot no longer starts

manic wing
#

.

ionic wadi
#

Yeh but did they take it offline or something

manic wing
#

no

#

it should still work fine

ionic wadi
#

Hmm

manic wing
#

if it worked a month ago and it’s the same code it will work fine rn

ionic wadi
#

weird

cloud dawn
#

Well mostly colabs here is to both know how to code.. hm

cloud dawn
slate swan
cloud dawn
slate swan
slate swan
#

like i do the prefix then energy and it doesnt do anything in terminal or chat

dapper cobalt
#

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

slate swan
#

yeah

#
**@client.command()
@commands.guild_only()
async def energy(ctx: commands.Context):
     energy = [ "Heres 5 hour of energy",
                "Heres one second of energy",
                "Heres 10 hours of energy",
                "Heres 24 hours of energy",
                "Heres 1.5 hours of energy",
                "Heres a week of energy",
                "Heres 2 weeks of energy",
                "Delete discord. Take a break",
     ]**
dapper cobalt
#

It seems like you've got no send method. You need to send a message. I believe what you're attempting is replying with a random item from that energy array; therefore, you'd need to do:

await ctx.send(random.choice(energy))
slate swan
#

How do I check if message.content is only sent from ctx.author?

if ctx.message.content == verification_code:
slate swan
#

How do I use that?

visual island
#

they're asking whether you're using wait_for or no

slate swan
#

No

visual island
#

then what are you using?

slate swan
peak loom
#

What has an atrubute to .send?

visual island
#

that will not work

visual island
slate swan
slate swan
peak loom
visual island
#

get_channel, or get_user

#

then use .send method there

peak loom
visual island
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**...
peak loom
#

What can I use with .send in an on_ready().

cloud dawn
peak loom
cloud dawn
#

You could but don't recommend it.

peak loom
#

I'm making where when the bot is alive it sends whats new.

peak loom
cloud dawn
slate swan
#

@pliant gulch ??????????????

cloud dawn
unkempt canyonBOT
#

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

Waits until the client’s internal cache is all ready.
peak loom
plain cloud
#

Once the bot is ready, you can send it yes. You’ll have to get the channel you want to send it in

cloud dawn
plain cloud
#

Dam I thought I knew what I was talking about nvm ducky_drawing don’t listen to me

slate swan
#

Just use discord.Client()

plain cloud
#

danny isn’t in here

slate swan
#

!documentation discord.Client

#

!docs discord.Client

unkempt canyonBOT
#

class discord.Client(*, loop=None, **options)```
Represents a client connection that connects to Discord. This class is used to interact with the Discord WebSocket and API.

A number of options can be passed to the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client").
slate swan
#

Use this @cloud dawn

cloud dawn
#

No...?? What are you talking about?

slate swan
#

What

cloud dawn
#

What wrong with bot?

#

!d discord.ext.commands.Bot

unkempt canyonBOT
#

class discord.ext.commands.Bot(command_prefix, help_command=<default-help-command>, description=None, **options)```
Represents a discord bot.

This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") you can do with this bot.

This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.
slate swan
slate swan
#

Freecodecamp told me discord.Client is better.

#

Than that shitty discord.ext.commands.Bot.

peak loom
#

I said help, now I'm confused.

plain cloud
#

It’s preference. I don’t think it really matters

slate swan
cloud dawn
#

Nah he is just trolling

slate swan
#

@pliant gulch ????????????????????

plain cloud
#

unfortunate

slate swan
slate swan
#

tfym tfim

plain cloud
#

um just under whatever you’re defining?

#

so like under where you’ve defined energy. Try there

slate swan
#

I switched to that shtty discord.ext.commands.Bot and now I have this error

#

from discord import discord as pycord
import discord.ext.commands

client = discord.ext.commands.Bot(command_prefix="!")

@client.command()
async def client(self, ctx):
    ctx.send("Hi")

client.run("my token")
```Pycord taught me this but there's some error
slate swan
#

Ok

#

and no need for self since your not in a class

#
import pycord
from pycord.ext import commands

client = discord.ext.commands.Bot(command_prefix="!")

@client.command()
async def client(self, ctx):
    ctx.send("Hi")

client.run("my token")
```Still an error
#

show

slate swan
#

good eye

#
import pycord
from pycord.ext import commands

client = discord.ext.commands.Bot(command_prefix="!")

@client.command()
async def client(self, ctx):
    await ("Hi")

client.run("my token")
```Like this?
plain cloud
#

await ctx.send(“hi”)

slate swan
#
await ctx.send()

since its a coro

cloud dawn
slate swan
#
import pycord
from pycord.ext import commands

client = pycord.Client(command_prefix="!")

@client.command()
async def client(self, ctx):
    await ctx.send("Hi")

client.run("my token")
```Like this?
slate swan
#

your using the bot framework

#

Bruh I'll just use discord.Client since it's so troublesome

cloud dawn
slate swan
#

!d discord.ext.commands.Bot

unkempt canyonBOT
#

class discord.ext.commands.Bot(command_prefix, help_command=<default-help-command>, description=None, **options)```
Represents a discord bot.

This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") you can do with this bot.

This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.
slate swan
#

lol

plain cloud
#

I’m having a hard time deciding if this is troll or not ducky_dave

slate swan
#

same here

heavy folio
#

@slate swan dont name your function 'client'

heavy folio
slate swan
heavy folio
#

LOL

cloud dawn
slate swan
#

Screw this... I give up

slate swan
#

🚶😭

cloud dawn
slate swan
heavy folio
#

Tutorials are fundamentally flawed in concept when it comes to teaching you something like a programming language. The simple reason for this is a programming language is how you create whatever you want, a tutorial is something that teaches you how to do *what the tutorial is teaching. *
I recommend reading through all of these points if you want to understand why
A couple of points against tutorials...especially video tutorials:

  • Tutorials teach you how to create a project, a specific program, a specific script, etc. This causes many many people to only know how to do this one specific thing.

  • A programming language is an entire language itself, this is obvious in of itself but for this point think of this compared to a real language...people have accents, there's multiple ways to say the same thing, there's multiple pronunciations for some words. This same kind of concept applies to programming languages, there are many ways to achieve the same thing, there are code styles which people pick up from learning. Sometimes...these practices can be bad and if you're just learning, how would you know if the tutorial is using some bad practice? Trust me...this happens **a lot **

  • Tutorials are made for that specific version of whatever it's using...whether this be python, the discord.py library, some other library it's using...etc. As time goes on that can very quickly become outdated

  • Sometimes there are "advanced" or hard concepts that are covered in a tutorial, you're not guaranteed to understand all of it right off the bat. It is extremely hard to provide the relevant documentation for every single concept covered....there would be so much.

  • Specifically for this library, the people who look for tutorials are typically new to the language...this library is not meant for beginners, there are some advanced concepts (EG asyncio) that are covered, and jumping straight into that as a beginner is very bad.

#

@slate swan ^

cloud dawn
# slate swan Why

It is not handy to name it client since that has a different meaning.

slate swan
cloud dawn
#

Pretty sure bad naming is part of the syntax lol

slate swan
#

command ideas?

pliant gulch
#

Making client.run error

#

And in general making client not actually a discord.Client instance

cloud dawn
#

True but if you are using commands.Bot you shouldn't run into that issue..

heavy folio
#

thing is

#

why even use discord.Client

slate swan
pliant gulch
heavy folio
#

and naming client your bot instance is a really bad idea

pliant gulch
#

Doesn't matter which client they use to communicate to the API

#

The naming matters

cloud dawn
# slate swan command ideas?

I recently was thinking about a anti command spam. That if you spam commands from the bot you get a global command cooldown.

#

Imagine naming everything a letter of the alphabet.

slate swan
#

idrk how to start with that

visual island
cloud dawn
plain cloud
heavy folio
#

oh yeah how do i set a global command cooldown (if someone spams x comamnds in more than y seconds)

slate swan
cloud dawn
pliant gulch
#

Say if you had a bot only for logging, that would be a good use case of Client

#

Not if you were to have 50 message commands

slate swan
plain cloud
#

True true

slate swan
#

sql is boring to me ._.

cloud dawn
#

sql i pretty fast and easy though

slate swan
#

yeah but i got bored of it lol

pliant gulch
#

You don't need an sql database here though prob

#

Just a redis cache will be fine

pliant gulch
#

Or a regular dict

slate swan
#

so any other command ideasjam_cavedude

cloud dawn
pliant gulch
slate swan
heavy folio
#

oh i didnt read lmao

pliant gulch
#

turn code into machine language

cloud dawn
#

You can just use on_command to get started.

slate swan
pliant gulch
#

I mean

#

With discord.py v2.0 you can just make a custom cooldown mapping

cloud dawn
#

Hmm activity command.

slate swan
plain cloud
#

Story creation!

cloud dawn
# slate swan pardon?

Use the raw api to request a url to make a activity room like the new discord poker or youtube together.

plain cloud
#

That’s not what I was talking about but sounds good too!!

pliant gulch
#

Make a voice receive command

slate swan
plain cloud
#

Valid

pliant gulch
#

Is youtube together even public?

#

Or is it still expirements

#

Otherwise I would've added to my wrapper already

cloud dawn
slate swan
#

guys i need a multimillion dollar idea😠

pliant gulch
#

Still waiting on text field components

heavy folio
cloud dawn
heavy folio
#

!pypi discord-together

unkempt canyonBOT
slate swan
plain cloud
#

Sounds like you need a 50 cent idea

cloud dawn
slate swan
pliant gulch
heavy folio
#

ohh

plain cloud
#

Make a command that picks a random image off like imgur

slate swan
plain cloud
#

cute cute

slate swan
#

Imgur != Reddit

slate swan
#

I already am

#

😖

cloud dawn
#

Everything we recommend isn't good enough.

slate swan
#

its still gets a random img ok

slate swan
#

🕵️‍♂️

dapper cobalt
cloud dawn
#

Emulate the Nswitch in the discord chat.

slate swan
cloud dawn
#

idk

slate swan
#

🧍‍♂️

cloud dawn
#

You asked for a million dollar idea you didn't say that it should be possible.

pliant gulch
#

Make discord but in discord

pliant gulch
#

Oh

cloud dawn
slate swan
pliant gulch
#

make a global chat

#

Cross server chat

slate swan
cloud dawn
manic wing
#

why

dapper cobalt
#

!ot I don't like being this guy.

unkempt canyonBOT
cloud dawn
#

Because... no ;-;

manic wing
slate swan
manic wing
#

which is one of the topics

plain cloud
#

Isn’t these discord bot ideas?

dapper cobalt
#

Ah, then you're good. tehee

cloud dawn
#

Yes this is very educational.

slate swan
#

any command that uses buttonspithink

manic wing
#

calc

cloud dawn
#

snake game in discord.

slate swan
#

pardon?

manic wing
#

make a really nice calculator

plain cloud
#

Rock Paper Scissors

slate swan
slate swan
manic wing
plain cloud
#

Heads up 7 up

slate swan
manic wing
#

mmhm

dapper cobalt
plain cloud
#

Make a command that blends your pfp with pictures

manic wing
#

dude

heavy folio
#
        async def global_spam_ratelimit(ctx):
            if ctx.author.id in self.owner_ids:
                return True
                
            bucket = self.cd.get_bucket(ctx.message)
            retry_after = bucket.update_rate_limit()
            if retry_after:
                raise GlobalRatelimitHit('You have hit the global spam ratelimit!')
            return True
```rn i have this but eh i want the owner to bypass this, for some reason it doesnt let me bypass the global cooldown
manic wing
#

just make a calculator

dapper cobalt
slate swan
#

really easy

dapper cobalt
plain cloud
manic wing
plain cloud
#

oh snap ducky_bear

plain cloud
#

Make a gaslight command

manic wing
dapper cobalt
slate swan
slate swan
cloud dawn
#

Make a command to start a minecraft server and have the console output inside the discord channel.

pliant gulch
#

Make a turing complete calculator

cloud dawn
#

Scientific calculator.

slate swan
plain cloud
#

Make a command… that makes new commands by editing your script 😌✌️

manic wing
dapper cobalt
# slate swan Both

It seems like you've got slight knowledge in Python. Nevertheless, your code should be like this:

@client.command()
@commands.guild_only()
async def energy(ctx: commands.Context):
  energy = ["Heres 5 hour of energy",
            "Heres one second of energy",
            "Heres 10 hours of energy",
            "Heres 24 hours of energy",
            "Heres 1.5 hours of energy",
            "Heres a week of energy",
            "Heres 2 weeks of energy",
            "Delete discord. Take a break"]
  await ctx.send(random.choice(energy))

Remember, you need to import random initially.

manic wing
manic wing
#

alg button is fucked

plain cloud
#

Unscientific calculator 🧍‍♂️

cloud dawn
#

A calculator that just outputs random ints

dapper cobalt
cloud dawn
#

Make a bot that can create other discord bots

dapper cobalt
plain cloud
#

not me starting discord.py with no code knowledge in 2019. It’s a miracle I still enjoy coding after that experience

dapper cobalt
cloud dawn
#

I started coding python in May this year.

manic wing
#

:O

slate swan
dapper cobalt
cloud dawn
cloud dawn
#

html, css some js

#

c# even and some C

dapper cobalt
cloud dawn
plain cloud
#

PHP more like Python (hython) python

pliant gulch
#

php lol

plain cloud
#

just kidding ✌️🥵😔ducky_santa

dapper cobalt
#

!ot Don't try to convince me PHP has anything to do with dpy. kekw

unkempt canyonBOT
plain cloud
#

you’re right

cloud dawn
#

I mean i can use a PHP script to controll my dpy application.

manic wing
plain cloud
#

Has anyone seen a discord chat bot? That formulates it’s own responses?

cloud dawn
#

You mean an AI?

dapper cobalt
manic wing
#

i wanna see a chatbot without py if bot.user: return 😎

plain cloud
#

Haha me too

plain cloud
plain cloud
manic wing
cloud dawn
plain cloud
#

I’ve been working on one that’s barely gone anywhere

#

But I’m working on it nonetheless

cloud dawn
#

Machine learning is pure predictions and speculation trained based of on a model. AI can make real time adjustments to that module.

pliant gulch
#

Quite the task, you need to tokenize things, weight tokens by how important they are. Then you gotta do all this nonsense with parsing

plain cloud
#

Gave it some categories like noun, verb, adjective, etc. taught it some words. Now it learns sentence structures by words it knows. It uses these sentence structures to decipher what a new word’s category is. Also have a check for surrounding word patterns to help assign new words.

#

Hit some roadblocks with English words falling in multiple categories but I’ve been working towards fixing that

pliant gulch
plain cloud
#

First I’m getting a non-emotion version. Very blank

#

Afterwards I’ll work on connotations

#

I already have it where it can identify the subject and predicate and preposition in sentences (if it knows the words)

pliant gulch
#

Training should be pretty simple too, depending on if you have an active discord server where the bot can listen onto

plain cloud
#

It’s a process 😤 too much brain power

#

Training is really simple. Problem is I let my activity slip in bigger servers during school so no one will add my bot lol

plain cloud
#

No idea what that stands for

cloud dawn
#

What are you using to train your bot then??

#

CNN?

plain cloud
#

It’s using discord messages

cloud dawn
#

Yeah using..? Keras? Tensorflow?

plain cloud
#

I made my own checks

#

It uses PyDictionary to remove words that aren’t words from my general check savefile

cloud dawn
#

So you are saying you made your own neural network algorithm?

plain cloud
#

I’ve made a learning algorithm definitely not neural network

#

It uses averages of message structures and commonly used surrounding words

cloud dawn
#

So an AI.

plain cloud
#

If that’s what you think an AI then sure lol

#

It’s not able to create a message based on subject yet because I will have to add some sort of connotation reader to create a message

cloud dawn
#

Your reasoning about how you created your chatbot is beyond my comprehension.

plain cloud
#

I’m sorry I’m bad at explaining 😅 when it’s done ima open it up on GitHub

pliant gulch
#

Your not using a neural network? This is gonna be hard to maintain

cloud dawn
plain cloud
#

Yeah I am aware but it’s kinda just a passtime thing

cloud dawn
#

Most use neural network module with numpy to train and get responses.

plain cloud
#

Ima look into it. Tbf I didn’t really know what to look for

#

My first version of this process was trash and didn’t do crap because it was a fat else: statement at the end of my on_message because I didn’t understand functions in 2019

cloud dawn
plain cloud
#

But it’s a lot more organized and better formatted now

#

Ima look into that, thanks!

cloud dawn
#

TensorFlow and keras do most of that heavy lifting though...

#

Now i want to do deep learning projects lol

plain cloud
#

It’s sm fun

shrewd inlet
#

i have 2 role commands that grant a user a role, one that gives and one that takes it away. i would like to make one role command and basically if the member doesn’t have the role it gives it to them but if they do have it, then it removes it. how could i make that possible? i need help please :)

plain cloud
#

From scratch it’s very satisfying watching it work

cloud dawn
#

if it has the role.. remove else.. add

shrewd inlet
shrewd inlet
#

and so the command can detect if the user has the role or not and decide whether to remove it or to add it

cloud dawn
plain cloud
#

You can do that in one command. It’ll be like an if else

shrewd inlet
cloud dawn
#

Could you send the code you have got so far?

plain cloud
#

All good 🙏 gotta start somewhere

shrewd inlet
#

🙏

cloud dawn
shrewd inlet
#

sorry for bothering but how can i make that command? 😅

shrewd inlet
vast gale
shrewd inlet
# cloud dawn Could you send the code you have got so far?
@bot.command()
async def addrole(ctx, role: discord.Role, user: discord.Member):
  if ctx.author.guild_permissions.administrator:
   embed = discord.Embed(description=f"Added {role.mention} to {user.mention}",color=0x2f3136)
   await user.add_roles(role)
   await ctx.send(embed=embed)

@bot.command()
async def removerole(ctx, role: discord.Role, user: discord.Member):
  if ctx.author.guild_permissions.administrator:
   embed = discord.Embed(description=f"Removed {role.mention} from {user.mention}",color=0x2f3136)
   await user.remove_roles(role)
   await ctx.send(embed=embed)
vast gale
#

!d discord.Member.roles

unkempt canyonBOT
#

property roles: List[Role]```
A [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") that the member belongs to. Note that the first element of this list is always the default [‘@everyone](mailto:'%40everyone)’ role.

These roles are sorted by their position in the role hierarchy.
vast gale
#

btw is this part of a public bot?

shrewd inlet
#

no, this is a private bot for my server

vast gale
#

okay cool

shrewd inlet
cloud dawn
#

I'm coding...

shrewd inlet
#

nice!!

vast gale
unkempt canyonBOT
#

@vast gale :white_check_mark: Your eval job has completed with return code 0.

001 | True
002 | False
vast gale
#

you can use that boolean logic to determine if you should use discord.Member.add_roles or discord.Member.remove_roles

pliant gulch
#

Clean way you could do is (add_roles, remove_role)[role in member.roles]

cloud dawn
#
import discord

from discord.ext.commands import Context, MemberConverter, RoleConverter
from discord.abc import Messageable

@bot.command(name='change_role', aliases=['cr'])
@commands.has_guild_permissions(administrator=True)
async def change_role(ctx: Context, role: RoleConverter = None, member: MemberConverter = None) -> discord.Message:
    if not role and not isinstance(role, discord.Role):
        return await ctx.send('Invalid role.')

    member = ctx.author or member
    embed = discord.Embed(description=f"Removed {role.mention} to {member.mention}", color=0x2f3136)

    if role in member.roles:
        await member.add_roles(role)
    else:
        await user.remove_roles(role)

    return await ctx.send(embed=embed)
pliant gulch
#

The return annotation is wrong kek

cloud dawn
#

Idk what it returns lol

vast gale
pliant gulch
#

Messageable.send returns the Message

#

The return type would be Message

cloud dawn
#

There xD

pliant gulch
#

Any?

cloud dawn
#

Could be any

vast gale
#

(you have to import Any)

cloud dawn
vast gale
#

and no, it'll be either discord.Message or None

cloud dawn
#

There xD

#

I'm going to sleep..

vast gale
cloud dawn
vast gale
#

also you don't need to import the converters, discord.py will calculate those automatically

#

can just type hint them with discord.Role and discord.Member

pliant gulch
vast gale
#

ye

cloud dawn
#

Preference

pliant gulch
#

Which part

cloud dawn
plain cloud
#

meth as a variable 😭😭

pliant gulch
#

Well it made sense to me

#

Meth as in method

plain cloud
#

ohhhhh okay lol

cloud dawn
#

Meth as in ...

plain cloud
#

That’s just so funny to me ducky_drawing

#

bout to look into tensor flow. brain go brrr

visual island
#

!e
a = (print(1), print)[1 + 1 == 2]
a(2)

unkempt canyonBOT
#

@visual island :white_check_mark: Your eval job has completed with return code 0.

001 | 1
002 | 2
cloud dawn
#

The person we were helping is long gone xD

visual island
#

hmm

cloud dawn
#

Well i was going to sleep 👋

#

forreal now lol

plain cloud
#

Farewell panda

pliant gulch
#

!e ```py
print(int(True))
print(int(False))

unkempt canyonBOT
#

@pliant gulch :white_check_mark: Your eval job has completed with return code 0.

001 | 1
002 | 0
pliant gulch
#

This is why (..., ...)[True] works along with False

heady lake
#

hi how to make a discord modmail bot using python? thank you so much!

slate swan
#

how do i make a cooldown for buttons do i disable it and then sleep and then enable it?

dapper cobalt
maiden fable
slate swan
slate swan
pliant gulch
unkempt canyonBOT
#

@pliant gulch :white_check_mark: Your eval job has completed with return code 0.

2
shrewd inlet
#

how do i make it so a command can only be used by a specific role?

slate swan
#

use has_role/has_any_role check

dapper cobalt
unkempt canyonBOT
#

@discord.ext.commands.has_role(item)```
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 invoking the command has the role specified via the name or ID specified.

If a string is specified, you must give the exact name of the role, including caps and spelling.

If an integer is specified, you must give the exact snowflake ID of the role.

If the message is invoked in a private message context then the check will return `False`.

This check raises one of two special exceptions, [`MissingRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") if the user is missing a role, or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") if it is used in a private message. Both inherit from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").

Changed in version 1.1: Raise [`MissingRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")
shrewd inlet
# dapper cobalt !d discord.ext.commands.has_role
@bot.command(discord.ext.commands.has_role(924841723753021490))
async def addrole(ctx, user: discord.Member, role: discord.Role):
   embed = discord.Embed(description=f"**Added {role.mention} to {user.mention}**",color=0x2f3136)
   await user.add_roles(role)
   await ctx.send(embed=embed)

@bot.command(discord.ext.commands.has_role(924841723753021490))
async def removerole(ctx, user: discord.Member, role: discord.Role):
   embed = discord.Embed(description=f"**Removed {role.mention} from {user.mention}**",color=0x2f3136)
   await user.remove_roles(role)
   await ctx.send(embed=embed)
#

is that correct?

boreal ravine
#

bruh

boreal ravine
#

and it's a decorator

shrewd inlet
#

oh

boreal ravine
#

add it to your command

shrewd inlet
#

sorry im new to do this

#

where do i add it?

boreal ravine
#

to your command

shrewd inlet
#

but like where or after what

boreal ravine
#

above/below @bot.command()

shrewd inlet
#

alr

dapper cobalt
maiden fable
shrewd inlet
#

ty

pliant gulch
#

Since python 3 has backwards compatibility with python 2 True is actually 1 and False is actually 0

maiden fable
#

Ah

manic wing
#

shit wrong person sorry

boreal ravine
#

Cool

manic wing
#

@maiden fable i found a reason for get_context

#

i have subclassed ctx and its very useful for me to have the ctx

visual island
#

I thought it was a new syntax or something

plain cloud
#

anyone here have a cool gucci discord bot

#

absolute beauty of a specimen of Python?

pliant gulch
#

I got a pretty cleanly written bot

plain cloud
#

A solid 10/10 very beautiful gucci specimen of Python

#

Thank youducky_lemon

pliant gulch
#

Pretty old code though

#

I write way better code nowadays

slate swan
#

whats the coro to edit a msgs content

pliant gulch
unkempt canyonBOT
#

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

Edits the message.

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

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

Yes

slate swan
pliant gulch
#

That's actually the name of it lol

#

And yes it's made with lefi

slate swan
dreamy sluice
#

Can someone help? This line is giving me errors.

@bot.command(name='8ball',
            description="Answers a yes/no question.",
            brief="Answers from the beyond.",
            aliases=['eight_ball', 'eightball', '8-ball', '8ball'],
            pass_context=True)

async def eight_ball(ctx, *argv): 
    if argv[0] == None or argv[0] == '':
      possible_responses = [
          '🎱 Totally no',
          '🎱 Not looking likely',
          '🎱 Too hard to tell',
          '🎱 Quite possible',
          '🎱 Definitely',
      ]

      await ctx.channel.send(random.choice(possible_responses))
    else:
      await ctx.send("No proper arguments given")
upbeat otter
#

And the errors are?

upbeat otter
dreamy sluice
upbeat otter
#

Close the string in the if @dreamy sluice

dreamy sluice
#

The single quotes?

upbeat otter
#

And its ctx.send

upbeat otter
boreal ravine
upbeat otter
#

.channel gives error somtimes but oki as you want

boreal ravine
#

how does it give an error?

dreamy sluice
upbeat otter
dreamy sluice
maiden fable
#

@dreamy sluice may I know why have u left a line in between the deco and the function?

upbeat otter
#

@maiden fable i've a question

maiden fable
#

Hm?

slate swan
#

i have a question as well lol

maiden fable
#

Hm?

maiden fable
upbeat otter
#

Does specifying a different name in the decorator and specifying a different one while initializing the function make any difference?

maiden fable
#

Yea

#

The name in the deco is dominant to the function name

upbeat otter
#

Oki

#

Ty

dreamy sluice
#

Welp, it still errors out.

boreal ravine
#

@dreamy sluice try restarting your bot

maiden fable
#

@dreamy sluice u sure there ain't any missing closing brackets on preceding lines?

maiden fable
#

Sometimes the error is cz of a missing )

upbeat otter
dreamy sluice
#

I might be dumb if I am being honest

upbeat otter
#

Not even an error marking

maiden fable
#

Weird

slate swan
boreal ravine
valid galleon
#

is there any way to check if the author has either one of the permissions specified, and if they do, the command will run? ik how to use @commands.has_permissions(), but afaik it only checks for one permission

dreamy sluice
upbeat otter
dreamy sluice
#

k

quick gust
maiden fable
#

Yes it is

slate swan
boreal ravine
maiden fable
maiden fable
slate swan
slate swan
quick gust
#

just change the embed set_image or whatever your image is set in

slate swan
#

i did

maiden fable
quick gust
#

then edit the message with the new embed...?

maiden fable
#

U can do message.embeds[0].set_image(...)

slate swan
boreal ravine
quick gust
#

still kinda unsure of what you're tryna do

maiden fable
#

@quick gust he's trying to edit an embed's image

quick gust
slate swan
#
await ctx.msgvar.edit(embedobj=newembedobj)

its wrong isnt it

maiden fable
#

No it isn't lol

boreal ravine
slate swan
#

Unresolved reference 'oldwallpaper'

heavy folio
quick gust
boreal ravine
maiden fable
boreal ravine
#

define oldwallpaper in your function, not in the global scope

maiden fable
#

But the power of **kwargs :DDD

slate swan
quick gust
slate swan
#

thats the old msg var

heavy folio
boreal ravine
boreal ravine
slate swan
#

hold up

dreamy sluice
#

Wait my bot now works

#

Repl wasn't showing me syntax errors my friend has done

slate swan
#

how do you edit an embed because i did

oldembed=newembed
dreamy sluice
#

It showed them when I refreshed.

boreal ravine
maiden fable
cerulean osprey
#
@client.command()
async def act(ctx, arg, activity):
    if ctx.author.id == 591047383044063244:
        if arg.lower() == "playing":
            await client.change_presence(activity=discord.Game(name=str(activity)))
            await ctx.send(f"My activity has been changed to 'Playing {activity}'")

        elif arg.lower() == "listening":
            await client.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name=str(activity)))
            await ctx.send(f"My activity has been changed to 'Listening to {activity}'")

        elif arg.lower() == "streaming":
            await client.change_presence(activity=discord.Streaming(name=str(activity), url="https://www.twitch.tv/sevendeadlywinds"))
            await ctx.send(f"My activity has been changed to 'Streaming {activity}'")

        elif arg.lower() == "watching":
            await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name=str(activity)))
            await ctx.send(f"My activity has been changed to 'Watching {activity}'")

        else:
            await ctx.send("Invalid Syntax Bozo")```
This is just giving me the `else:` back. Prior to adding `.lower()` it worked just fine. What did I do wrong?
slate swan
boreal ravine
#

yes

slate swan
#

i still get the stupid error tho

cerulean osprey
#

Wym?

quick gust
#

do you mind sharing what u are doing because the examples you are giving aren't helping us help you

boreal ravine
maiden fable
slate swan
cerulean osprey
#

-act listening "Wind yell at me"

slate swan
boreal ravine
#

send() returns a Message object when you use it

cerulean osprey
#

That worked prior to me adding .lower()

maiden fable
#

Hmm

slate swan
#

wait

#

fck it was indentation

#

wasnt in the if statement i had gosh my bad guys

boreal ravine
#

oof

slate swan
#

thank you everyone

quick gust
maiden fable
#

No

slate swan
cerulean osprey
#

The quotes make it take it all

slate swan
#

so i turned off errors

quick gust
#

oh they do?

cerulean osprey
#

Yeah

maiden fable
#

It will take the whole string @quick gust

boreal ravine
quick gust
#

good to know

slate swan
cerulean osprey
#

Although I should add a *, thx for reminding me

quick gust
#

np

cerulean osprey
#

Wait so whats the difference between * and **

maiden fable
#

!args-kwargs

unkempt canyonBOT
#

*args and **kwargs

These special parameters allow functions to take arbitrary amounts of positional and keyword arguments. The names args and kwargs are purely convention, and could be named any other valid variable name. The special functionality comes from the single and double asterisks (*). If both are used in a function signature, *args must appear before **kwargs.

Single asterisk
*args will ingest an arbitrary amount of positional arguments, and store it in a tuple. If there are parameters after *args in the parameter list with no default value, they will become required keyword arguments by default.

Double asterisk
**kwargs will ingest an arbitrary amount of keyword arguments, and store it in a dictionary. There can be no additional parameters after **kwargs in the parameter list.

Use cases
Decorators (see !tags decorators)
Inheritance (overriding methods)
Future proofing (in the case of the first two bullet points, if the parameters change, your code won't break)
Flexibility (writing functions that behave like dict() or print())

See !tags positional-keyword for information about positional and keyword arguments

soft lynx
#

hey

cerulean osprey
#

Ty

soft lynx
#

@slash.slash(
      name="view",
      description="select a country from a continent",
      guild_ids=[877730319434919946])

async def view(ctx: SlashContext, args=None):

    # north-america; Canada, USA, Mexico

    dictionary = { 
      "north-america": [924737989341503609, 924737988800438322, 924737997503627265]
    }```
boreal ravine
#

?

soft lynx
#

so basically, im making a group of roles, per continent
and then i want to use a command (ex: !show-north-america)
and it will display the roles in North America that no one in the server currently has
this is a server specific command

#

    elif args == "North America" or "NA23":
      for country in dictionary["north-america"]:
       guild = ctx.guild
       role = discord.utils.get(guild.roles) 
  # role = get_role(country)
       if len(role.members) == 0:
          await ctx.send(role)
slate swan
soft lynx
#

im not getting an error, however, its simply not working

slate swan
#

can someone help?

soft lynx
#

should work

slate swan
#

thanks

cerulean osprey
soft lynx
#

i still cant identify exactly why its not working

slate swan
soft lynx
#

is what im trying to check

slate swan
#

oh nvm I read it wrong , what r u trying to do btw

soft lynx
#

i have a dictionary, with roles. i want a user to invoke a command that sends every single role within that dictionary that no one in the server currently has

slate swan
#

utils.get takes a name/id parameter too

#

Oof

soft lynx
#

To check if anyone on the guild has the role?

brittle harness
#
if message.content.startswith.case_insensitive("$Hello"):
        await message.channel.send("Hello!")

Would this allow for the bot to be case insensitive?

#

I have been stuck on case insensitive for awhile.

slate swan
#

In that case role.members will never be 0

soft lynx
#

Unless I did something that was like guild.roles minus one

sage otter
slate swan
#

i got my bot to play music

slate swan
#

lets gooooooo

sage otter
#

commands.Bot takes allows you to pass case_insensitive into its constructer

soft lynx
brittle harness
sage otter
#

how so?

slate swan
sage otter
#

Got any errors?

brittle harness
#

It still needs a capitol at the start.

#

Idk why.

soft lynx
alpine vault
#

My bot (gets ratelimited?) Cannot add emotes after adding about ~30 emotes to an said guild, I've tried imposing and sleep statement in between addition of emotes like await asyncio.sleep(2) but that doesn't seem to help either.
How can i go about this?

heavy folio
small igloo
soft lynx
#

I want it to check if anyone has those roles @slate swan and if not, send their IDS in the channel it was invoked in

sage otter
#

Are you still trying to make commands with that
if message.content.startswith() shit?

#

if so, that makes sense why it wont work

slate swan
sage otter
#

if you wanted to do it that way. Which no one here would recommend. You would convert the string to lower case .
For example:

if message.content.lower().startswith("!hello"):
    await message.channel.send("hi")
brittle harness
sage otter
sage otter
#

add parenthesis to lower

#

its a method

#

I honestly dont know why people who use dpy dont use the commands framework. Like its already built into the package you install from pypi or git. Unlike d.js's commando or akairo framework. Its honestly just wasteful.

#

Its like people trying to re-invent the wheel.

hardy yoke
soft lynx
#


    elif args == "North America" or "NA23":
      for country in dictionary["north-america"]:
       role = ctx.guild.get_role(id)
       if len(role.members) == 0:
          await ctx.send(role)
slate swan
soft lynx
#

members is not an object of role

slate swan
#

the role id is invalid

#

Ez

#

And what's the variable id ?

soft lynx
slate swan
#

You should be using get_role(country) since that's the elements of list

slate swan
#

no you coded it wrong

soft lynx
slate swan
#

Yeah

crude crater
green brook
#

hi

#

my code is massive

slate swan
#

ok

soft lynx
crude crater
unkempt canyonBOT
#

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

green brook
soft lynx
#


    elif args == "North America" or "NA23":
      for country in dictionary["north-america"]:
       role = ctx.guild.get_role(country)
       if len(role.members) == 0:
          await ctx.send(role)
green brook
soft lynx
#

i updated the code tho

soft lynx
slate swan
green brook
soft lynx
green brook
#

!rule 9

unkempt canyonBOT
#

9. Do not offer or ask for paid work of any kind.

soft lynx
#

async def view(ctx: SlashContext, args=None):

    # north-america; Canada, USA, Mexico

    dictionary = { 
      "north-america": [924737989341503609, 924737988800438322, 924737997503627265]
    }
green brook
#

mhm

visual island
#

!ot

unkempt canyonBOT
green brook
#

hhe

brittle harness
slate swan
sage otter
#

Youll end up making it harder for yourself.

#

Take advantage of what you already have. Work smarter not harder.

brittle harness
#

So should I scrap some of my code and rebuild?

hardy yoke
sage otter
#

That would be ideal. So later in development you dont get inconvenienced.

soft lynx
#
    elif args == "North America" or "NA23":
      role_ids : list = dictionary ["north-america"]
      for role_id in role_ids:
        role = ctx.guild.get_role(role_id)
        if len(role.members) == 0:
          await ctx.send(role)
small igloo
#

so i use global last_level and the terminal says this, what's wrong

SyntaxError: name 'last_level' is used prior to global declaration

code:

@bot.command()
@commands.cooldown(1, 40, commands.BucketType.user)
async def exercise(ctx):
    name = ctx.author.id
    energy = database.check_energy(name)
    coin = database.check_coin(name)
    if coin > 50:
        if energy > 20:
            exp = random.randint(10, 50)
            database.add_exp(name, int(exp))
            last_level = database.check_level(name)
            database.check(name)
            level = database.check_level(name)
            database.energy_decrease(name, 20)
            database.decrease_coin(name, 50)
            await ctx.send(f"{ctx.author.mention} is paying :money:50 to exercise, but {ctx.author.mention} getting {exp}XP!")
            if last_level != level:
                global last_level
                last_level = level
                await ctx.send(f"GG, {ctx.author.mention} is getting a level")
        else:
            await ctx.send("HEH u already tired, go sleep first (or u can use meal if u have one)")
    else:
        await ctx.send("not enough coin sorry :(")
slate swan
soft lynx
#

i have one more formatting question, and thanks for all your help btw

#


    elif args == "North America" or "NA23":
      role_ids : list = dictionary ["north-america"]
      for role_id in role_ids:
        role = ctx.guild.get_role(role_id)
        if len(role.members) == 0:
          await ctx.send(role.name)

right now its sending a separate message for each role
how can i make it send all of the role.name in one message?
this is probably pretty basic

small igloo
visual island
visual island
#

global is confusing

small igloo
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!

small igloo
#

what

#

oh, just use bot."name"

#

?

soft lynx
sage otter
# soft lynx wdym by comps

List comprehensions
await ctx.send(", ".join([ctx.guild.get_role(id).name for id in role_ids if not len(ctx.guild.get_role(id).members)]))
Rough sketch but something like this

#

Wrote on mobile so theres probably a fault in there somewhere.

small igloo
soft lynx
#

is there a way to just make it send it once

sage otter
#

Take it out of the for loop

soft lynx
#

rightt

sage otter
#

everything in that list comprehension does all of that shit your for loop does

soft lynx
#

i want it to only send the roles within the dictionary that no users have

#

    elif args == "North America" or "NA23":
      role_ids : list = dictionary ["north-america"]
      for role_id in role_ids:
        role = ctx.guild.get_role(role_id)
        if len(role.members) == 0:
          await ctx.send(", ".join([ctx.guild.get_role(id).name for id in role_ids if not len(ctx.guild.get_role(id).members)]))
#

here is the current code

sage otter
#

Not sure why its still in your for loop but ok. Honestly that should of worked SH_z_02_shrug.
if not ctx.guild.get_role(id).members works too
Remove the for loop entirely. The await ctx.send(....) should be right under the role_ids declaration

magic ore
#

Got code that looks like this, and it's not working properly?

if x == "foo" or "bar" or "baz":

Python is interpreting this as though it was this:

if (x == "foo") or ("bar") or ("baz"):

If the first expression (x == "foo") isn't true, the second ("bar") will be, so this compound conditional always passes.
Try this instead: py if x == "foo" or x == "bar" or x == "baz": or, even better: ```py
if x in ("foo", "bar", "baz"):

slate swan
#

Hi so im trying to make it play music but in a file it can play music out of the file but i want it to be in a music file

#

how do i do that?

#

i alr have the code

visual island
#

pass "music/file.mp3" in the arg then

slate swan
#

so music/file.mp3 arg

#

?

#

put in the brackets obv

#

or just use FFmpegPCMAudio("music/"+arg) if all the music files are in the same directory named music

final iron
#

!or

unkempt canyonBOT
#

When checking if something is equal to one thing or another, you might think that this is possible:

if favorite_fruit == 'grapefruit' or 'lemon':
    print("That's a weird favorite fruit to have.")

While this makes sense in English, it may not behave the way you would expect. In Python, you should have complete instructions on both sides of the logical operator.

So, if you want to check if something is equal to one thing or another, there are two common ways:

# Like this...
if favorite_fruit == 'grapefruit' or favorite_fruit == 'lemon':
    print("That's a weird favorite fruit to have.")

# ...or like this.
if favorite_fruit in ('grapefruit', 'lemon'):
    print("That's a weird favorite fruit to have.")
soft lynx
#

this helps simply the problem, however

#

the bot will still include IDs of roles that people already have

#

the goal is for the bot to only show the roles that people do no thave

heavy folio
#

is there any way to make a reconnect command? meaning the bot logs out then relogs in

slate swan
#

using bot.close and os.system("python <your bot file>") may work

soft lynx
#

nvm, i tested it and i cant

#

can you explain how i can make it send the list as pings

slate swan
#

From your code earlier

[ ctx.guild.get_role(role_id) for role_id in role_ids if not len(ctx.guild.get_role(role_id))]``` must be the thing
#

You can use.join on it

soft lynx
slate swan
#

You want to mention the role?

soft lynx
#

yeah

slate swan
#
",".join([ ctx.guild.get_role(role_id).mention for role_id in role_ids if not len(ctx.guild.get_role(role_id).members)])```
#

Role has mention attribute

soft lynx
#

oh

#

didnt know that was an attribute

soft lynx
#
      role_ids : list = dictionary ["north-america"]

      await ctx.send(", ".join([ctx.guild.get_role(role_id).mention for role_id in role_ids if not ctx.guild.get_role(role_id)]))```
#

is it giving me an error bc it thinks that all of the roles are already occupied?

tiny ibex
soft lynx
#

thats what it says in its readme

tiny ibex
#

It works for my friend atleast

#

With the same code

boreal ravine
tiny ibex
boreal ravine
#

its an extension for dpy

tiny ibex
boreal ravine
#

so its not related

#

make a issue on the github

#

why ask here

tiny ibex
#

Very dumb logic of yours

tiny ibex
slate swan
#

oh nvm the list is empty

#

And use .members at the last , I forgot to add it

boreal ravine
boreal ravine
soft lynx
# slate swan Updated

the code works, except its still sending the roles which users within the server already have

boreal ravine
# tiny ibex So?

"This project is currently under development. We do not guarantee it works."
make a issue on the github

soft lynx
#

for example, i have this role:

soft lynx
#

but the message still contains it

tiny ibex
slate swan
boreal ravine
#

it gave a wav file

slate swan
#

!e py if len([]): print("works")

unkempt canyonBOT
#

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

[No output]
slate swan
#

yea it should work

tiny ibex
soft lynx
slate swan
#

how can i make command that changes commands language cuz i dont wonna have problem with sameone who dont understanding polish sentensens sorry for my grammar spelling and english

#

has this ever happend to anyone?

soft lynx
slate swan
boreal ravine
#

reddit users

slate swan
#

its a discord client

boreal ravine
tiny ibex
slate swan
#

ive never had it happen with users or bots

#

good thing i use pycharm nowpithink

slate swan
tiny ibex
slate swan
#

why?

tiny ibex
#

And run again

boreal ravine
slate swan
boreal ravine
#

it doesnt make a difference

tiny ibex
slate swan
#

okay why tho

#

OH THATS WHY

boreal ravine
tiny ibex
slate swan
#

i mostly dont make many request so i probably wouldn't get ratelimited anyways

#

yeah ik