G
G
Guerro692020-06-20 22:34:12
Python
Guerro69, 2020-06-20 22:34:12

Discord.py how to find out what message needs to be changed through @bot.event?

I have this code:

import discord, re
from time import *
from function import *
import datetime
import asyncio
from discord.ext import commands

token, bot, p, tag = session()
bot.remove_command('help')
online = 0

@bot.event
async def on_voice_state_update(member, before, after):
  global online
  if before.channel == None and after.channel != None:
    msg = discord.Message(723981384435236925)
    online -= 1
    await msg.edit(content=f'Голосовой онлайн: {online}')

  elif before.channel != None and after.channel == None:
    msg = discord.Message(723981384435236925)
    online -= 1
    await msg.edit(content=f'Голосовой онлайн: {online}')


That is, when a person joins a voice channel, the bot must edit its message.
But the question is how to tell the bot which message to change, and I only have the message id, and discord.Message does not work in this case.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
shurshur, 2020-06-21
@Guerro69

For example,
msg = await channel.fetch_message(723981384435236925)
(Here channel is the channel with the desired message)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question