I have a $allservers
command in my discord bot and reached the text limit from 2.000 characters. So I'm asking, is it possible to get the server list from a MySQL database and put them into multiple messages?
Example:
FIRST MESSAGE: server1, server2, server3
-- REACHED TEXT LIMIT, NEXT MESSAGE
SECOND MESSAGE: server4, server5, server6
My code for the $allservers
command:
@bot.command(aliases=["servers"])
async def allservers(ctx):
mydb = mysql.connector.connect(
host="**",
user="**",
password="**",
database="**"
)
mycursor = mydb.cursor()
guild56 = bot.get_guild(616655040614236160)
member = guild56.get_member(ctx.author.id)
role2 = guild56.get_role(792894127972155393) # Admin
role3 = guild56.get_role(792894172829974529) # Mod
if role2 in member.roles or role3 in member.roles:
mycursor.execute(f"SELECT * FROM servers")
myresult = mycursor.fetchall()
message = ''
for x in myresult:
try:
x1 = [x]
guild = bot.get_guild(int(x1[0][0]))
channel = bot.get_channel(int(x1[0][1]))
message += f'**{guild}** - `{channel.name}` - `{guild.id}`
'
except:
pass
await ctx.author.send(f"??** | ALLE SERVERS**
{message}")
await ctx.message.delete()
My bot is on many servers, that's why the bot reached the discord message text limit from 2.000 characters.
question from:
https://stackoverflow.com/questions/65644187/discord-py-server-list-in-multiple-messages 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…