.repinv now posts in the channel repeater originates from, not current one
This commit is contained in:
parent
a0e363ff66
commit
bece18dffc
@ -36,6 +36,7 @@ namespace NadekoBot.Modules.Utility
|
||||
public Repeater Repeater { get; }
|
||||
public SocketGuild Guild { get; }
|
||||
public ITextChannel Channel { get; private set; }
|
||||
private IUserMessage oldMsg = null;
|
||||
|
||||
public RepeatRunner(Repeater repeater, ITextChannel channel = null)
|
||||
{
|
||||
@ -52,14 +53,23 @@ namespace NadekoBot.Modules.Utility
|
||||
{
|
||||
source = new CancellationTokenSource();
|
||||
token = source.Token;
|
||||
IUserMessage oldMsg = null;
|
||||
try
|
||||
{
|
||||
while (!token.IsCancellationRequested)
|
||||
{
|
||||
var toSend = "🔄 " + Repeater.Message;
|
||||
await Task.Delay(Repeater.Interval, token).ConfigureAwait(false);
|
||||
|
||||
await Trigger().ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public async Task Trigger()
|
||||
{
|
||||
var toSend = "🔄 " + Repeater.Message;
|
||||
//var lastMsgInChannel = (await Channel.GetMessagesAsync(2)).FirstOrDefault();
|
||||
// if (lastMsgInChannel.Id == oldMsg?.Id) //don't send if it's the same message in the channel
|
||||
// continue;
|
||||
@ -96,11 +106,6 @@ namespace NadekoBot.Modules.Utility
|
||||
_log.Warn(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
@ -176,9 +181,10 @@ namespace NadekoBot.Modules.Utility
|
||||
return;
|
||||
}
|
||||
var repeater = repList[index].Repeater;
|
||||
|
||||
repList[index].Reset();
|
||||
await Context.Channel.SendMessageAsync("🔄 " + repeater.Message).ConfigureAwait(false);
|
||||
await repList[index].Trigger();
|
||||
|
||||
await Context.Channel.SendMessageAsync("🔄").ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
|
Loading…
Reference in New Issue
Block a user