在多行上发送消息
我试图获取我的工具以自动在Discord服务器中发送消息,但是,我的消息不止一行。我尝试使用将其全部放入一行,然后使用“ \ n”来获取新行。但这不起作用。它仅读取整个消息的底部消息。我将消息输入邮件。txt,因此用户不必编辑程序。 这是函数 +发送消息函数
的
def loadmessages():
lines = []
with open('messages.txt') as f:
lines = f.readlines()
#had trouble formatting code
定义
def send_messages(message_data,):
connection = get_connection()
m=dumps(message_data)
with open("Channel ID's.txt","r") as f:
ChannelIDs = f.read().split("\n")
for channel in ChannelIDs:
send_message(connection, channel,m,)
sleep(5)
repeat()
Im trying to get my tool to send a message automatically in discord servers, However, My message is more than one line. I tried using putting it all in one line and using '\n' to get a new line. But that doesn't work. It only reads the bottom message of the entire message. I have the message put in a message.txt so the user doesn't have to edit the programme.
Here's the definition of the function + the send message function, LMK if you need anything else
#Message
def loadmessages():
lines = []
with open('messages.txt') as f:
lines = f.readlines()
#had trouble formatting code
#Send message
def send_messages(message_data,):
connection = get_connection()
m=dumps(message_data)
with open("Channel ID's.txt","r") as f:
ChannelIDs = f.read().split("\n")
for channel in ChannelIDs:
send_message(connection, channel,m,)
sleep(5)
repeat()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您随时可以将文件的文本读为变量。例如:
You can always read a text of a file into variable. For example: