コード例 #1
0
def main(message: Message, discord_object: DiscordBot.DiscordBot):
    user = message.author
    isMember = False
    NSFW = discord.utils.get(message.server.roles, name='Guilty Eyes')
    for role in user.roles[1:]:
        if role == NSFW:
            isMember = True

    if not isMember:
        yield from discord_object.add_roles(user, NSFW)
        yield from discord_object.send_message(
            message.channel,
            user.mention + ' You now have access to the NSFW channel.')
    else:
        yield from discord_object.remove_roles(user, NSFW)
        yield from discord_object.send_message(
            message.channel, user.mention +
            ' Your access to the NSFW channel has been revoked.')
コード例 #2
0
ファイル: invasionalert.py プロジェクト: jeyoo98/oceDiscord
def main(message: Message, discord_object: DiscordBot.DiscordBot):
    user = message.author
    isMember = False
    KritiasWatch = discord.utils.get(message.server.roles,
                                     name='Kritias Watch')
    for role in user.roles[1:]:
        if role == KritiasWatch:
            isMember = True

    if not isMember:
        yield from discord_object.add_roles(user, KritiasWatch)
        yield from discord_object.send_message(
            message.channel, user.mention +
            ' You have been added to the Kritias Invasion alert.')
    else:
        yield from discord_object.remove_roles(user, KritiasWatch)
        yield from discord_object.send_message(
            message.channel, user.mention +
            ' You have been removed from the Kritias Invasion alert.')