1
votes

I want to create a discord bot that erases the message from the channel People left

I tried this:

        if before.channel:
            for role in serverroles:
                rooles.append(get(self.guild.roles, name=role))
            await self.remove_roles(*rooles)
            if before.channel.members == []:
                chn = before.channel.id
                if chn == 743323003932115076:
                    channels = client.get_channel(ch1)
                    await channels.purge(limit=999)
                if chn == 743323035200913509:
                    channels = client.get_channel(ch2)
                    await channels.purge(limit=999)
                if chn == 743323078725075064:
                    channels = client.get_channel(ch3)
                    await channels.purge(limit=999)
                if chn == 743323177500803094:
                    channels = client.get_channel(ch4)
                    await channels.purge(limit=999)```

and I got AttributeError: 'VoiceChannel' object has no attribute 'purge'
1
There is no message in a voice channel, is there?Pac0
@Pac0 I agree. It seems like its purging on any channel and it should check to make sure it's in a TextChannelJacob

1 Answers

1
votes

The event is called on_voice_state_update, as the name says, it is for Voice channels and VoiceChannel can not be purged as there are no messages in it.