Verification system. (discordpy)
To answer your question, fetch_guild
makes an API call and is a coroutine, so any calls to it should be awaited. It also accepts an int
as a parameter, not a Guild
, and you probably don't want to be comparing a Guild
to an int
either.
However, it seems that you're making unnecessary function calls anyway - you shouldn't need to call get_guild
or fetch_guild
at all. Just calling get_channel
should be enough since the return type will be None
if your bot account isn't in the guild anyway (as the channel won't be found).
With that in mind, you can change your code as such:
channel = client.get_channel(930910261332819968)
text = discord.Embed(title="React below to verify.", color=discord.Colour.blue())
if channel:
moji = await channel.send(embed=text)
await moji.add_reaction('✔')
A few other improvements were also made in the above code snippet, namely using TextChannel.send
and Message.add_reaction
in favor of Client.send_message
and Client.add_reaction
, respectively.
You should also keep in mind that a new verification message will be sent each time you run your bot unless you add a mechanism to prevent that. You may also want to use fetch_channel
rather than get_channel
to prevent any cache issues.