Skip to content

Instantly share code, notes, and snippets.

@gfrn
Created May 29, 2021 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gfrn/f3eaca70dd7103e63ea68c2363f1f523 to your computer and use it in GitHub Desktop.
Save gfrn/f3eaca70dd7103e63ea68c2363f1f523 to your computer and use it in GitHub Desktop.
Discord bot that relays messages to users anonymously
import discord
from discord.ext import commands
import os
intents = discord.Intents.default()
intents.members = True
bot = commands.Bot(command_prefix='$', intents=intents)
@bot.command()
async def send(ctx, target, msg, signature="anon"):
try:
user = bot.get_user(int(target))
await user.send(f"{msg}\n~{signature}")
await ctx.send(f"Mensagem enviada com sucesso para @{user}!")
except (ValueError, TypeError, commands.errors.CommandInvokeError):
await ctx.send("Syntax: $send id \"message\" \"signature\" (optional)")
bot.run(os.getenv('TOKEN'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment