tetsuya-ki / discord-reminderbot Goto Github PK
View Code? Open in Web Editor NEWDiscord用のリマインダーBotです(discord reminder bot)。
License: MIT License
Discord用のリマインダーBotです(discord reminder bot)。
License: MIT License
# Sticker取得のため、ギルドの取得
guild = await self.bot.fetch_guild(remind[2])
2023-05-19 20:35:24,659@ discord.ext.tasks [ERROR] _error: Unhandled exception in internal background task 'printer'.
Traceback (most recent call last):
File "/home/ubuntu/python/discord-reminderbotpublic3/.venv/lib/python3.10/site-packages/discord/ext/tasks/init.py", line 239, in _loop
await self.coro(*args, **kwargs)
File "/home/ubuntu/python/discord-reminderbotpublic3/cogs/remindercog.py", line 70, in printer
guild = await self.bot.fetch_guild(remind[2])
File "/home/ubuntu/python/discord-reminderbotpublic3/.venv/lib/python3.10/site-packages/discord/client.py", line 2246, in fetch_guild
data = await self.http.get_guild(guild_id, with_counts=with_counts)
File "/home/ubuntu/python/discord-reminderbotpublic3/.venv/lib/python3.10/site-packages/discord/http.py", line 740, in request
raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10004)
エラーが発生しました(local variable 'channel_id' referenced before assignment)
channel_idがない状態で、
_remind_makeの以下のところへ到達してエラーが発生
id = await self.remind.make(guild_id, ctx.author.id, remind_datetime, message, channel_id, status, repeat_flg,
repeat_interval, repeat_count, repeat_max_count)
#16 の対応で生まれたバグ
エラーメッセージ
エラーが発生しました('NoneType' object has no attribute 'id')
下記部分のせいでダメ
ファイル: remindercog.py
メソッド: remind_cancel
await self.remind.update_status(id, ctx.guild.id, self.remind.STATUS_CANCELED)
こちらのreminderbotを使用させていただいております。
いつもありがとうございます。
こちら/remind-makeのmessageで改行を使用する方法はございますでしょうか?
以下のような形式で時間の指定を可能にする(hh24:mi形式か、hやmiが付かないとエラーとする)
2021-09-05 15:01:05,061@ asyncio [ERROR] default_exception_handler: Task exception was never retrieved
future: <Task finished name='Task-252' coro=<Loop._loop() done, defined at /opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/tasks/__init__.py:88> exception=Forbidden('403 Forbidden (error code: 50001): Missing Access')>
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/tasks/__init__.py", line 125, in _loop
raise exc
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/tasks/__init__.py", line 101, in _loop
await self.coro(*args, **kwargs)
File "/home/runner/discord-reminderbot/cogs/remindercog.py", line 73, in printer
await channel.send(remind[5])
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord_slash/dpy_overrides.py", line 323, in send_override
return await send(channel, *args, **kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord_slash/dpy_overrides.py", line 300, in send
data = await state.http.send_message(
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py", line 248, in request
raise Forbidden(r, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access
オプションで繰り返し間隔を設定させる
こういうエラーになってしまい、リマインドしなくなるのでtry-catchで対処が必要。
2022-04-29 15:09:09,879@ asyncio [ERROR] default_exception_handler: Task exception was never retrieved
future: <Task finished name='Task-651' coro=<Loop._loop() done, defined at /opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/tasks/__init__.py:88> exception=TypeError("'NoneType' object is not iterable")>
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/tasks/__init__.py", line 125, in _loop
raise exc
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/tasks/__init__.py", line 101, in _loop
await self.coro(*args, **kwargs)
File "/home/runner/discord-reminderbotpublic3/cogs/remindercog.py", line 53, in printer
for remind in self.remind.remind_rows:
TypeError: 'NoneType' object is not iterable
Unhandled exception in internal background task 'printer'.
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/tasks/__init__.py", line 101, in _loop
await self.coro(*args, **kwargs)
File "/home/runner/discord-reminderbotpublic3/cogs/remindercog.py", line 67, in printer
remind_msg = await channel.send(remind[5])
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord_slash/dpy_overrides.py", line 323, in send_override
return await send(channel, *args, **kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord_slash/dpy_overrides.py", line 300, in send
data = await state.http.send_message(
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py", line 248, in request
raise Forbidden(r, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50007): Cannot send messages to this user
突然電源が落ちてもデータが消えない仕組みになっていると嬉しい
9b09f55 で追加しましたが、今までは繰り返し間隔はノーチェックでした...
そのため、繰り返し間隔が不正とわかったとき、こっそり処理をしないようにしていました...
今回、そのチェックを追加しました。数字がなく、単位のみの場合、1があるとみなすようにしました。
それでこういうエラーが発生して、Taskが中止されて、リマインドされない事態になっている気がする
今まで登録されちゃったものもあると思うので、printerメソッドの繰り返し回数チェックのところに、remind[8].isdecimal()みたいなチェックを追加しようかな
2021-09-05 14:41:39,664@ asyncio [ERROR] default_exception_handler: Task exception was never retrieved
future: <Task finished name='Task-66' coro=<Loop._loop() done, defined at /opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/tasks/__init__.py:88> exception=TypeError("'<' not supported between instances of 'int' and 'str'")>
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/tasks/__init__.py", line 125, in _loop
raise exc
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/tasks/__init__.py", line 101, in _loop
await self.coro(*args, **kwargs)
File "/home/runner/discord-reminderbot/cogs/remindercog.py", line 94, in printer
if remind[8] is None or repeat_count < remind[8]:
TypeError: '<' not supported between instances of 'int' and 'str'
平日の9時、12時、15時に予約投稿をし、repeatの機能で自動で再登録、という形で使わせていただいております。
普段は問題なく稼働しているのですが、週に1~2度ほど、予約投稿が行われずに、17時過ぎとか終わってから順次9時、12時、15時の投稿がされていくといった事象が起きております。
こちらを解消したいのですが、この投稿時間は何の時間を参照しているのでしょうか。
Discord側の設定に依存するものでしょうか。
一時的なリマインドキャンセル機能(もしくは2種の繰り返し間隔設定)があるとありがたいです。
例として、[毎日][6:00]から[1時間]毎に送信されるリマインドを作成し、その日のリマインドをキャンセルしても翌日にはまた同じリマインドが再開される、というような事ができると助かります。
/remind-make
コマンドでリマインドを作成すると、レスポンス?で「 xxxxBot が考え中...」が表示され、消えないctx.send ()
だけでもいいのだけど、最初にctx.respond()
を するのがオススメらしいctx.respond()
をつけるべきだし、15分以上かかるならctx.defer()`が必要とのこと# Case 1
await ctx.respond() # This is optional, but still recommended to.
msg = await ctx.send("Hello, World! This is initial message.")
await msg.edit(content="Or nevermind.")
await msg.delete()
await ctx.send("This is followup message.")
# Case 2
await ctx.respond(eat=True) # Again, this is optional, but still recommended to.
await ctx.send("This is secret message.", hidden=True)
毎日9:00に投稿できるようなbotがないかと探しており、こちらにたどり着きました。
早速使わせていただいております、ありがとうございます!
repeat_interval機能についてですが、こちらの登録を試しているのですが「繰り返し間隔が不正のため、リマインドを登録できませんでした」と出て登録ができません。/rimind-makeで表示されるテンプレートからと、下記のように直接入力の両方を試しております。
入力方法に不備がありますでしょうか。repeat_intervalを外せば登録はできます。
/remind-make date:0705 time:12:41 message:テスト投稿 repeat_interval:平日
〇やりたいこと
理想は平日のAM9:00にメッセージを投稿したいと考えております。
毎日手動で7/2、7/3と1件ずつ登録していくのが手間なので、理想は平日というカテゴリーで登録をかけたいのですがエラーが解消できませんので、質問させていただきました。
URLのみを繰り返し投稿したい場合、URLが壊れてしまうため
URL<スペース> URLやURL<改行>URL等色々パターンありそうだけど一旦は簡単なものだけ対応する
ENABLE_SLASH_COMMAND_GUILD_ID_LISTが初期値のまま動かすとエラーになってしまうことに気づいた。
remindercog.pyのintにするやつを以下のようにすると動く。
map(int, setting.ENABLE_SLASH_COMMAND_GUILD_ID_LIST.split(';')))
--
map(lambda x: x if x.isdigit() else '', setting.ENABLE_SLASH_COMMAND_GUILD_ID_LIST.split(';')))
掲題の通り。スレッドはチャンネルと違うので、登録できなかった。
ちょっと一手間かければ登録可能であるため、対処。
Ignoring exception in command None:
discord.ext.commands.errors.CommandNotFound: Command "remind-list" is not found
ギルドでリマインドを辞めたくなった時、ギルドのデータを一気に削除する機能が必要。
論理削除だけじゃなくて物理削除までやる。
IS_HEROKU
がTrueの場合、Herokuモードになる古いリマインドを削除する必要があるのだと思う。
削除した状態でもリマインド登録できないなら、容量オーバーてきな何か表示が必要なのかもしれない...。
100ギルドくらいで使った場合とかの話だと思うので、急がなくてもいい気がする。
リマインドを辞めたくなった時、自分のデータを一気に削除する機能が必要。
論理削除だけじゃなくて物理削除までやる。
2022-07-10 23:45:01,221@ reminderbot [INFO] _remind_task_check: remindのTaskを確認するぜ!
2022-07-10 23:45:01,221@ reminderbot [INFO] check_printer_is_running: Taskが停止していたので再起動します。
2022-07-10 23:45:01,222@ asyncio [ERROR] default_exception_handler: Task exception was never retrieved
future: <Task finished name='Task-4590' coro=<Loop._loop() done, defined at /opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/tasks/init.py:88> exception=AttributeError("'VoiceChannel' object has no attribute 'send'")>
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/tasks/init.py", line 125, in _loop
raise exc
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/tasks/init.py", line 101, in _loop
await self.coro(*args, **kwargs)
File "/home/runner/discord-reminderbotpublic3/cogs/remindercog.py", line 81, in printer
remind_msg = await channel.send(remind[5])
AttributeError: 'VoiceChannel' object has no attribute 'send'
こんにちは。今後こちらのBOTを使わせていただきたく、テストをしてみたのですが、
/remind-cancelを実行してもNoが違いますと出てしまい、取り消しすることができませんでした。
こちらの過去ログも見てみたのですが、リマインドキャンセルができるオーナーになるためには
どのような作業が必要なのでしょうか?
テスト自体は自分がサーバーのオーナーで管理者のサーバーで実施しています。
こういったことに詳しくなく、的はずれな質問でしたら大変申し訳ございません。
お手数をおかけしますが、ご返信いただけますと幸いです。
よろしくお願いいたします。
/remind-list
を実行すると、エラーが発生するINFO:cogs.remindercog:remindをlistするぜ!
INFO:cogs.modules.remind:
ERROR:discord_slash:An exception has occurred while executing command `remind-list`:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord_slash/client.py", line 690, in invoke_command
await func.invoke(ctx, **args)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord_slash/model.py", line 131, in invoke
return await self.func(self.cog, *args, **kwargs)
File "/home/runner/discord-reminderbot/cogs/remindercog.py", line 144, in remind_list
await ctx.send(content=rows)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord_slash/context.py", line 184, in send
resp = await self._http.post(base, self.interaction_id, self.__token, files=files)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py", line 247, in request
raise HTTPException(r, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50006): Cannot send an empty message
int型なのにisdecimal()とか無いぞという至極当たり前のエラーが出たので、修正が必要
なんでいつもはエラーが出ないんだろう?
2021-10-01 12:44:21,645@ reminderbot [INFO] check_printer_is_running: Taskが停止していたので再起動します。
2021-10-01 12:44:21,645@ asyncio [ERROR] default_exception_handler: Task exception was never retrieved
future: <Task finished name='Task-28' coro=<Loop._loop() done, defined at /opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/tasks/__init__.py:88> exception=AttributeError("'int' object has no attribute 'isdecimal'")>
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/tasks/__init__.py", line 125, in _loop
raise exc
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/tasks/__init__.py", line 101, in _loop
await self.coro(*args, **kwargs)
File "/home/runner/discord-reminderbotaj/cogs/remindercog.py", line 117, in printer
if remind[8] is None or (remind[8].isdecimal() and repeat_count < remind[8]):
AttributeError: 'int' object has no attribute 'isdecimal'
繰り返し対象のリマインドについて、ギルドをフェッチして例外が発生しないかチェックし、
例外が発生した場合は繰り返し設定を解除し、次回のリマインド登録をしないよう修正
await self.bot.fetch_guild(remind[2])
こちらのreminderを毎日繰り返しで使用しておりますが、(81)からremindをしなくなりました。
1/3まではリマインドできていましたが、原因をご確認いただけますでしょうか
よろしくお願いいたします。
No. 306908 No. 306910
ちゃんとtry-catchしておくべきだった...
こういうこうとされてしまうと、そもそもギルドにチャンネルを勝手に作って云々っていうのが悪んじゃないか?って気がしてくる。DMのときのように指定のギルドへファイル添付で済ませておけば、問題は発生しなかったはず。
その場合でも指定のギルドが使えなくなった場合に困ってしまうが...。
banlist的なテーブル作って、Discord IDを保存。
そこに登録された場合、リマインドを登録できない。
表示とかもできないようにするかは考えてない。
いつまで使えないかも登録できる
id DiscordID startDate EndDate createDate
作りたい理由。reminderbotの使い方がおかしい人がいるかもしれないため(例えば、1分間に1回リマインドを超たくさん作って荒らすなど)
それを教えてもらうため、運営者にメッセージを送るコマンドも必要なのかもしれない(やりたくない....)
https://discord-py-slash-command.readthedocs.io/en/latest/migration.html#migrate-to-v1-1-0
SlashContext the methods .respond and .ack have been removed
.respondは使っているので削除する必要がありそう
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.