Created
August 15, 2022 18:21
-
-
Save sekika/aff133b238bdfb8ebc1e67ec89bf7f44 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import discord | |
class Client(discord.Client): | |
async def on_ready(self): | |
if hasattr(self, 'action'): | |
for action in self.action: | |
if action[0] == 1: | |
user = await self.fetch_user(action[1]) | |
await user.send(action[2]) | |
if action[0] == 2: | |
channel = self.get_channel(action[1]) | |
await channel.send(action[2]) | |
await self.close() | |
def send_dm(self, user_id, message): | |
if not hasattr(self, 'action'): | |
self.action = [] | |
self.action.append((1, user_id, message)) | |
def send_channel(self, channel_id, message): | |
if not hasattr(self, 'action'): | |
self.action = [] | |
self.action.append((2, channel_id, message)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Discord 簡易ボット
https://sekika.github.io/2022/08/16/discord-bot/