現在、Pythonで、DiscordのBot (Vsync版)を作っています。
ただ、以下のようなことがあって、あまり良い作品ができません。
・現在独学で勉強している。
・Pythonも含め、discord.pyが圧倒的初心者。
・プログラミング言語をあまり書いたことがない。
・まだ中学生で、他のBot作成者等と話す機会がない/話しにくい。
個人的には以下の動作をしたいです。
・役職の追加
・サーバーに参加した際、役職を付与
・一度打ったコマンドは数時間経たないと再度打てない
また、現在のコードでおかしい文や、これはこうした方が良いなどありましたら、指摘願います。
python
1import discord 2import asyncio 3import os 4from datetime import datetime 5import importlib 6 7token = "(token)" 8client = discord.Client() 9 10time = datetime.now().strftime("%Y/%m/%d %H:%M") 11 12 13# 準備完了 14@client.event 15async def on_ready(): 16 print("") 17 print("「" + client.user.name + "」にログインしました。") 18 print("") 19 print("> 招待URL: https://discordapp.com/api/oauth2/authorize?client_id=" + client.user.id + "&permissions=0&scope=bot") 20 print("") 21 22 23# メッセージイベント 24@client.event 25async def on_message(message): 26 27 #「●●」サーバーだった場合 28 if message.server.id == "(serverid)": 29 30 #参加 31 if message.content.startswith("bot join"): 32 role = discord.utils.get(message.author.server.roles, name="Member") 33 await client.add_roles(message.author, role) 34 reply = f"{message.author.mention}さんがメンバーになりました!" 35 await client.send_message(message.channel, reply) 36 37 # テキストチャンネル作成 38 if message.content.startswith("bot addtext"): 39 channel_name = message.content.split()[1] 40 await client.create_channel(message.server, channel_name, type=discord.ChannelType.text) 41 reply = "テキストチャンネル「" + channel_name + "」を作成しました。" 42 await client.send_message(message.channel, reply) 43 44 # ボイスチャンネル作成 45 if message.content.startswith("bot addvoice"): 46 channel_name = message.content.split()[1] 47 await client.create_channel(message.server, channel_name, type=discord.ChannelType.voice) 48 reply = "ボイスチャンネル「" + channel_name + "」を作成しました。" 49 await client.send_message(message.channel, reply) 50 51 # Bot起動確認 52 if message.content.startswith("bot"): 53 reply = time + " | " + client.user.name + "は起動中です。" 54 await client.send_message(message.channel, reply) 55 56 57 58client.run(token) 59
それと、できれば常に相談出来る先生のような存在が居てほしいです。
ご協力お願いいたします。
discordならdiscordで。人がいそうなところに行けば、そういう方に会えるかもです。
https://disboard.org/ja/servers/tag/%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9F%E3%83%B3%E3%82%B0